CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2004
    Location
    Holy Land
    Posts
    306

    GROUP BY returns zero rows...

    I have an sql query that looks like this :
    Code:
    SELECT table.ID , AVG(*) as AVERAGE , ... , ... from table WHERE X > 200 GROUP BY table.ID ORDER BY AVERAGE
    this query qorks great...
    everytime there's more than one row in the table, but when theres only one row, it returns zero rows!
    I think this is because of the GROUP BY Statement, but im not sure...
    How can I prevent this from happening????
    Rate this post if you found it useful!
    10X, gilly914

  2. #2
    Join Date
    Nov 2005
    Posts
    49

    Re: GROUP BY returns zero rows...

    can u explain ur query like ID is primary key? and ON WHICH COLUMN YOU WANT AVERAGE?
    Muhammad Waqas Badar

  3. #3
    Join Date
    Jul 2007
    Location
    Sweden
    Posts
    331

    Re: GROUP BY returns zero rows...

    It would help if you posted a more complete query. It's obvious that you've removed important things such as joins (or you wouldn't be grouping on an ID.)

  4. #4
    Join Date
    Sep 2006
    Posts
    635

    Re: GROUP BY returns zero rows...

    Quote Originally Posted by gilly914
    everytime there's more than one row in the table, but when theres only one row, it returns zero rows!
    I think this is because of the GROUP BY Statement, but im not sure...
    How can I prevent this from happening????

    'select' returns Zero rows when 'Where' or 'Having' statements doesn't
    find some row.

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

Featured