Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How can I make this selection

Author  Topic 

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2009-01-20 : 04:27:00
Hai
I have a table in which fields are Id,price,quantity,Amount
If I have values like this in my table

Id price quantity Amount
1 25 5 125
1 25 5 100
2 20 4 80
2 20 1 20
1 25 10 250

how can I make a query to result

Id price quantity Amount
1 25 20 475
2 20 5 100

ie sum of the quantity and Amount rows with same Id

Regards,
Anu Palavila



Thanks and Regards
Anu Palavila

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-20 : 04:43:20
select id,price sum(quantity) as quantity, sum(amount)as amount from urtable group by id, price
Go to Top of Page

anupalavila
Yak Posting Veteran

56 Posts

Posted - 2009-01-20 : 07:03:12
Thakns bklr for your valuable replay

Thanks and Regards
Anu Palavila
Go to Top of Page

ra.shinde
Posting Yak Master

103 Posts

Posted - 2009-01-20 : 07:05:34
1 25 5 100
It has to be 1 25 5 125

Rahul Shinde
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-20 : 07:52:05
quote:
Originally posted by anupalavila

Thakns bklr for your valuable replay

Thanks and Regards
Anu Palavila



ur welcome
Go to Top of Page
   

- Advertisement -