Page 1 of 1

how to use group by in two ield in mysql

Posted: Tue Mar 02, 2010 1:32 am
by manojsemwal1
hai i have a table where student enter accordingly to their category and instituteid wise .

i want to see the student report to their category and instituteid wise how to make a query.........
i ran the follow query.........
SELECT Category, COUNT( StudentID ) AS Sum
FROM studentregdtb
GROUP BY Category
LIMIT 0 , 30

its gives only category wise student sum record.....but how to get in institutewise also..........

thanks

Re: how to use group by in two ield in mysql

Posted: Tue Mar 02, 2010 3:17 pm
by Christopher
Add instituteid to the GROUP BY. See the docs.

Re: how to use group by in two ield in mysql

Posted: Tue Mar 02, 2010 5:36 pm
by mikosiko
Try this

Code: Select all

SELECT InstituteId, Category, COUNT( StudentID ) AS Sum
FROM studentregdtb
GROUP BY InstituteId,Category
LIMIT 0 , 30