Results 1 to 4 of 4

Thread: Group By

  1. #1
    Join Date
    Aug 2006
    Posts
    3

    Group By

    I'm trying to run this statement:

    select ppn_i,cpn_i,bomcat_i from tbi..bm010115
    where ppn_i = 'BDS-2570'
    group by bomcat_i

    and was getting this error:
    Server: Msg 8120, Level 16, State 1, Line 1
    Column 'tbi..bm010115.PPN_I' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    When GROUP BY is specified, either each column in any non-aggregate expression in the select list should be included in the GROUP BY list, or the GROUP BY expression must match exactly the select list expression.

  3. #3
    Join Date
    Aug 2006
    Posts
    3
    finally figured it out. i was using the wrong statement, it was ORDER BY but I was curious with your post. can give me a sample statement utilizing GROUP BY. Thanks.

  4. #4
    Join Date
    Sep 2002
    Posts
    5,938
    You can find samples in books online.

Posting Permissions

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