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

2005-05-11 Thread Michael Stassen
Paul DuBois wrote: At 18:36 + 5/11/05, shaun thornburgh wrote: Hi, I keep getting thw following error when i include this line: AND COUNT(SUBSTRING(PRACT_NUMBER, 1, 4)) > 1 mysql> SELECT PRACT_NUMBER, -> COUNT(SUBSTRING(PRACT_NUMBER, 1, 4)) -> FROM CSV_Upload_Data -> WHERE CSV_File = '

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

2005-05-11 Thread Stefan Kuhn
I would guess it's because you can't use an aggregate function in where, but only in having. So use select group by PRACT_NUMBER having COUNT(SUBSTRING(PRACT_NUMBER, 1, 4)) > 1. The reason is that where is applied before the count is done, whereas having after that. And you can't select by

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

2005-05-11 Thread Paul DuBois
At 18:36 + 5/11/05, shaun thornburgh wrote: Hi, I keep getting thw following error when i include this line: AND COUNT(SUBSTRING(PRACT_NUMBER, 1, 4)) > 1 mysql> SELECT PRACT_NUMBER, -> COUNT(SUBSTRING(PRACT_NUMBER, 1, 4)) -> FROM CSV_Upload_Data -> WHERE CSV_File = 'ICS' -> AND CHAR