Hi, Im getting "1111 - Invalid use of group function" error on this function SUM(TIMESTAMPDIFF(HOUR,MIN(logDateTime),MAX(logDateTime))-1) as `rendered` is there a turn around on how to fix this problem? here is my full query: SELECT MIN(logDateTime) as `login`, MAX(logDateTime) as`logout`, SUM(TIMESTAMPDIFF(HOUR,MIN(logDateTime),MAX(logDateTime))-1) as `rendered` FROM btms_attendance WHERE `number`=1 AND (DATE(logDateTime)>='2022-03-01' AND DATE(logDateTime)<='2022-03-31') GROUP BY DATE(logDateTime) ASC Thank you