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)
 sum records within column

Author  Topic 

dirwin26
Yak Posting Veteran

81 Posts

Posted - 2005-09-22 : 10:28:20
Can anyone tell me how I can sum records within a column? I was referencing the specific records I needed with the date column, but the dates continually change based on my input, so I need to be able to tell sql to move up the column as opposed to telling it to grab the records which correspond to specific dates.

Any help would be appreciated,
Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-22 : 10:34:43
Can you post table Structure, sample data and the result you want?

Madhivanan

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

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2005-09-22 : 10:35:21
SELECT SUM(myColumn) AS [My happy sum column] FROM MyTable WHERE (conditions)

Help us help YOU!
Read this blog entry for more details: http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx

*need more coffee*
SELECT * FROM Users WHERE CLUE > 0
(0 row(s) affected)
Go to Top of Page

dirwin26
Yak Posting Veteran

81 Posts

Posted - 2005-09-22 : 10:58:04
#Table structure

ID Revnues Date
7 100 2005-10-1
7 100 2005-11-1
7 100 2005-12-1

I need to add the revenues for november and december. I am having problems using the WHERE clause because the date will change depending on which Id is displayed in the temp table.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-22 : 11:08:04
Is this?

Select sum(Revenues) from yourTable where Datecol between Date1 and Date2

Madhivanan

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

- Advertisement -