Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

ERROR 1111 (HY000): Invalid use of group function MYSQL

I want show the result

SELECT GolDarah, count(GolDarah) JmlPasien
FROM tblPasien
WHERE monthname(TglLahir) IN ('July','August','September','October','November','December') AND count(GolDarah) JmlPasien = 2
GROUP BY GolDarah
ORDER BY GolDarah;

I Want show the result, but error.
ERROR 1111 (HY000): Invalid use of group function

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You should to use HAVING statement like:

    SELECT GolDarah, count(GolDarah) JmlPasien
    FROM tblPasien
    WHERE monthname(TglLahir) IN ('July','August','September','October','November','December') 
    GROUP BY GolDarah
    HAVING count(GolDarah) = 2
    ORDER BY GolDarah;

also WHERE statement can be more effective like:

 WHERE month(TglLahir) > 5
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading