Can't group on error.
Greetings! I'm trying to get the top library users, when the user borrowed and returned a book 10 times or more, s/he belongs to the top library users. Here is my sql commant.
My problem is I can't group it by total , error says that 'cant group on total' ..
SELECT sb.stud_Id, COUNT(sb.stud_Id) >=10 AS total
FROM tbl_studentbook AS sb
LEFT JOIN tbl_student AS s ON s.id = sb.stud_Id
WHERE sbook_Borrow != '0000-00-00' AND sbook_Return != '0000-00-00'
GROUP BY total
My purpose upon grouping it is that it will show only the id that pass the total value of 10.
Any help? thank you.
where sbook_Return <> '0000-00-00'
group by stud_id
having count(*) > 10
Thak you very much for the quick response sir. I works now.