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
 Transact-SQL (2000)
 Need help with Sum

Author  Topic 

heathergilster
Starting Member

1 Post

Posted - 2007-04-02 : 15:03:24
Ok, here's what I have:

Table 1

DAY Price QTY
Tuesday $50 3
Tuesday $50 5
Wednesday $80 2
Wednesday $80 2
Thursday $20 2
Thursday $20 2

What I need to do is sum the Price and QTY columns based on the DAY column. Essentially where it's Tuesday it would say:

Tuesday $100 8

Please help!

NeilG
Aged Yak Warrior

530 Posts

Posted - 2007-04-02 : 15:19:04
I would use something along the lines of the following


select [Day] , sum(price)as [Total price], Sum(qty) as [Total Qty]
from table
group by [Day]

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-04-02 : 23:38:06
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -