Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Posts
    17

    Unanswered: 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

  2. #2
    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

  3. #3
    Join Date
    Feb 2004
    Posts
    17
    Thanks!

    That works a treat...

    even works in M$SQL...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •