Results 1 to 3 of 3

Thread: Agg op question

  1. #1
    Join Date
    Feb 2003
    Posts
    15

    Unanswered: Agg op question

    hi,

    i have a table 'Details' with columns [id int; level varchar(20)]. i want to get two things from one single query:
    1) the total number of items with Details.id=xxx
    2) all the associated [level] text

    i tried a few times doing things like:
    SELECT [Level], COUNT(*) FROM Details WHERE id=xxx GROUP BY id

    but it either gives me error "Column [Level] is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause."

    i am using MS SQL Server as the back engine and T-SQL in Access...

    Help~

    thanks in advance

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Agg op question

    Perhaps you can do this:

    select level, (select count(*) from details where id=xxx) as cnt
    from details where id=xxx;

    Works in Oracle, I don't know about your DBMS.

  3. #3
    Join Date
    Feb 2003
    Posts
    15
    Beautifully done~ thanks!

Posting Permissions

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