I want to get all rows that have count(AID)>5
When i do the query as :
SELECT x,y,z, COUNT(AID) as total from Table where ... Having total >5
It return the rows With total > 5 grouped ! but not all rows !
I want each row ..
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s not how aggregate queries work. The count is done over a range of records (whichever ones meet the conditions of the
WHEREclause) and then theHAVINGclause filters out anything with a count less than 5. If you want the specific rows that contributed to the count you might try something like…of course, this assumes that
x,y,zare a unique key forTable. If this is not the case, then this approach may not work.Also, are you missing a
group byclause?