I am trying to count the number of rows whose date has not yet passed so i can get only the current records
I get an error sayng
MySQL error #111 Invalid use of group function
SELECT COUNT(festivalid) FROM festivals WHERE min(datefrom) > now()
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.
The reason for the error is that you can not use aggregate (IE: MIN, MAX, COUNT…) functions in the
WHEREclause – only in theHAVINGclause can you do this. And to define theHAVINGclause, your query needs to have aGROUP BYclause defined:…but I have my doubts about the query, and think it would be better to use:
CURRENT_TIMESTAMPis ANSI standard equivalent to MySQL specificNOW(), making the query portable to other databases.