claro — 2012-03-16T10:33:03-04:00 — #1
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.
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 problem is I can't group it by total , error says that 'cant group on 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.
swampboogie — 2012-03-16T11:03:18-04:00 — #2
where sbook_Return <> '0000-00-00'
group by stud_id
having count(*) > 10
claro — 2012-03-16T11:13:02-04:00 — #3
Thak you very much for the quick response sir. I works now.
mittineague — 2014-09-23T19:43:17-04:00 — #4
This topic is now archived. It is frozen and cannot be changed in any way.