DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Script that adds up the value multiple rows in the same Table

  1. #1
    Join Date
    Mar 2005
    Posts
    143

    Script that adds up the value multiple rows in the same Table

    I need help writing a script that adds up an amount feild of several rows in a table. Here is the situation. I have a 9i db and there is a table called ex_sheet_vw that stores information about employees expense reports. The table looks like this:
    sheet_id emplid line amount
    000001 123 1 30.00
    000001 123 2 20.00
    000002 124 1 10.00
    000002 124 2 5.00
    000002 124 3 2.00
    What I need is a script that shows the emplid sheet_id and total amount for each expense report. Some reports have one line some have 2 some 3 it all depends and the amount of lines are different. But I would need to know that sheet_id 000001 was for $50.00. and 000002 was for $17.00. Any advice would be greatly appreciated.

  2. #2
    Join Date
    Nov 2002
    Location
    Geneva Switzerland
    Posts
    3,142
    Code:
    Select sheet_id, emplid, sum(amount)
    From   ex_sheet_vw
    Group  by sheet_id, emplid
    "The power of instruction is seldom of much efficacy except in those happy dispositions where it is almost superfluous" - Gibbon, quoted by R.P.Feynman

  3. #3
    Join Date
    Nov 2000
    Location
    Pittsburgh, PA
    Posts
    4,166
    Quote Originally Posted by DaPi
    Code:
    Select sheet_id, emplid, sum(amount)
    From   ex_sheet_vw
    Group  by sheet_id, emplid
    You really have a knack for making the complex look simple!

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