If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Invalid use of group function

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-18-05, 07:18
cstevio cstevio is offline
Registered User
 
Join Date: Feb 2004
Posts: 17
Invalid use of group function

Hi,

I'm trying to run the following query:

mysql> SELECT
-> ad.id appid,
-> ad.name name,
-> count(rd.id) refs
-> FROM applicantDetails ad
-> LEFT OUTER JOIN referenceDetails rd ON (rd.applicantid = ad.id)
-> WHERE count(rd.id) < 2
-> GROUP BY ad.id, ad.name;

and I get this err message, it's quite annoying as I've managed to do this many times before in MSSQL.

ERROR 1111 (HY000): Invalid use of group function

Does anybody know what could be causing this, I'm using the latest version of MYSQL.

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 10-18-05, 07:27
tombell tombell is offline
Registered User
 
Join Date: Jun 2005
Posts: 23
Code:
SELECT
 ad.id AS appid,
 ad.name AS name,
 count(rd.id) AS refs
FROM applicantDetails ad
 LEFT OUTER JOIN referenceDetails rd 
ON (rd.applicantid = ad.id)
 GROUP BY ad.id, ad.name
 HAVING count(rd.id) < 2
Reply With Quote
  #3 (permalink)  
Old 10-18-05, 07:40
cstevio cstevio is offline
Registered User
 
Join Date: Feb 2004
Posts: 17
Thanks!

That works a treat...

even works in M$SQL...
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On