Results 1 to 4 of 4

Thread: Invalid Use Of Group Function

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Invalid Use Of Group Function

    Can anyone offer a solution?

    Code:
    SQL query: Documentation
    
    SELECT tblscorerel.scoreid, tblscores.id, sum( tblscores.score )
    FROM tblscorerel
    INNER JOIN tblscores ON tblscorerel.scoreid = tblscores.id
    ORDER BY sum( tblscores.score )
    
    MySQL said: Documentation
    #1111 - Invalid use of group function
    Side note, this works in MySql 5. But my host will not upgrade my client to version 5 so I'm stuck on 4. Can anyone offer a work around?
    Last edited by Pino; Mar 30th, 2008 at 11:21 AM.

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Invalid Use Of Group Function

    Add this missing GROUP BY statement

    Code:
    SELECT tblscorerel.scoreid, tblscores.id, sum( tblscores.score )
    FROM tblscorerel
    INNER JOIN tblscores ON tblscorerel.scoreid = tblscores.id
    Group by tblscorerel.scoreid, tblscores.id
    ORDER BY sum( tblscores.score )

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: Invalid Use Of Group Function

    Still getting the same error..

    Code:
    SQL query: Documentation
    
    SELECT tblscorerel.scoreid, tblscores.id, sum( tblscores.score )
    FROM tblscorerel
    INNER JOIN tblscores ON tblscorerel.scoreid = tblscores.id
    GROUP BY tblscorerel.scoreid, tblscores.id
    ORDER BY sum( tblscores.score )
    LIMIT 0 , 30
    
    MySQL said: Documentation
    #1111 - Invalid use of group function

  4. #4
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: Invalid Use Of Group Function

    Remove the ORDER BY - does it work now?

    If it does then try adding

    ORDER BY 3

    and see if that works.

    I'm not familiar with MySQL - so that's about as far as my help can go!

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

Posting Permissions

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



Click Here to Expand Forum to Full Width