Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sum of some Columns

Status
Not open for further replies.

amerbaig

IS-IT--Management
Sep 4, 2001
58
0
0
CA
I have a table with two columns

CustomerId ---- Varchar
Order_Amount ----- Integer

Now data is

Customer Order_Amount
Riz 100
Biz 200
Ciz 300
Tiz 400
Hiz 500
Uiz 600

I want to get rows whoses sum of order_amount is 500

Please help me out


Regards,

Amer
 
select customerId from <table>
group by customerId having sum(order_amount) = 500

Hope it helps.

Shantha. Talent is what you possess;
genius is what possesses you

 
Output sould be

Result 1

Customer Order_Amount
Riz 100
Tiz 400

Result 2

Customer Order_Amount
Biz 200
Ciz 300


I need both output as one output.


 
This is similar to another recent post. I don't think you can do this with SQL; it's going to take a fair amount of looping to do this so I think you'll need to use a procedural language like PL/SQL.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top