Results 1 to 3 of 3

Thread: SQL - COMPUTE

  1. #1

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Singapore
    Posts
    43

    Post

    Hi all,

    How do i use the Compute statement as in the following example:

    (I'm trying to sum up the total bill of all those Vendor who are in the same dept, AR is my table name)

    Code:
    Select dept, Vendor, TotalBill From AR Group By Dept Order By Dept Compute Sum(TotalBill)

    I know this format is wrong somewhere, as in compute should come first or did i miss out any command ? Hope someone can correct me.

    Thks a lot.

  2. #2
    Frenzied Member
    Join Date
    Aug 1999
    Location
    Santa Clara, Ca , 95058
    Posts
    1,105

    Post

    Your statement will only give the summary for all the data (grand total), once you get rid of the group by that is. In order to have dept totals as well, you need to do:

    Code:
    Select dept, Vendor, TotalBill 
      From AR 
        Order By Dept 
          Compute Sum(TotalBill) by dept
          Compute Sum(TotalBill)


    [This message has been edited by JHausmann (edited 09-17-1999).]

  3. #3

    Thread Starter
    Member
    Join Date
    Aug 1999
    Location
    Singapore
    Posts
    43

    Post

    Thks a lot.

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