Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    SFO
    Posts
    3

    Unanswered: Compute By Clause problem in SQL 2000

    I am having a problem with this compute by clause

    The statement is a simple select

    Select col1, col2 from table1
    where <where clause>
    order by col1
    Compute Sum(col2) by col1

    I want the display to show details and group totals.

    The error message I keep getting is
    Server: Msg 410, Level 16, State 2, Line 1
    COMPUTE clause #1 'BY' expression #1 is not in the order by list.


    I have previously used the compute clause so I know it should work !!

    Ay help will be appreciated - Thank you.

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    This is working for pubs - I do not see the difference.

    SELECT type, price
    FROM titles
    ORDER BY type
    COMPUTE SUM(price) BY type

  3. #3
    Join Date
    Feb 2004
    Location
    SFO
    Posts
    3
    I saw this very same example and did my query and it doesn't work. I don't have the pubs database so I created a titles table and inserted some data and then ran this same query and that too gave me the same error !!!



    Originally posted by snail
    This is working for pubs - I do not see the difference.

    SELECT type, price
    FROM titles
    ORDER BY type
    COMPUTE SUM(price) BY type

  4. #4
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    Originally posted by CSC
    I saw this very same example and did my query and it doesn't work. I don't have the pubs database so I created a titles table and inserted some data and then ran this same query and that too gave me the same error !!!
    I am afraid you have a problem with your sql server - is it microsoft 2000?

  5. #5
    Join Date
    Feb 2004
    Location
    SFO
    Posts
    3
    Yes it is Microsoft Sql Server 2000. This is really strange !!


    Originally posted by snail
    I am afraid you have a problem with your sql server - is it microsoft 2000?

Posting Permissions

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