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
 General SQL Server Forums
 New to SQL Server Programming
 Trying to Sum monthlyExpenses to ytdExpenses

Author  Topic 

Michael71
Posting Yak Master

126 Posts

Posted - 2006-10-16 : 12:09:41
I have a Monthlyexpense column. How do I Sum up this column and put the Total in my ytdexpenses column. Do I use a stored procedure, because I want the monthlyExpenses to SUm up every time I submit a monthly expense to the database and siplay in the ytdExpenses Column.
When I Write a Query all of the rows in the ytdExpenses shows the same amount and do not total up every time I submit to the database. Help please.

monthlyExpenses ytdExpenses
$1,000 $1,000
$2,000 $3,000
$3,000 $6,000
$2,000 $8,000
$5,000 $13,000

khtan
Flowing Fount of Yak Knowledge


Singapore
3773 Posts

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-10-16 : 12:24:47
If you want a total, you actually have to program it. Just calling it YTD Expenses will not get data into the column.

Also, your table doesn't make much sense to me. If you have a column for monthlyExpenses, how do you know which month it is or who the expsnse is for?



CODO ERGO SUM
Go to Top of Page

Michael71
Posting Yak Master

126 Posts

Posted - 2006-10-16 : 12:28:13
Michael Valentine....the month is for the date it was filled out...it's for that department...I know you have to program it...but with what?
Go to Top of Page

Michael71
Posting Yak Master

126 Posts

Posted - 2006-10-16 : 12:30:09
Can Anyone help me out...instead of asking questions that I already know.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-10-16 : 12:34:57
Your table doesn't have the data element month or department, so how do you kwow? Or did you just not provide that information?



CODO ERGO SUM
Go to Top of Page

Michael71
Posting Yak Master

126 Posts

Posted - 2006-10-16 : 12:40:01
It's only one department and I did not provide that information? What do you mean about data Element?
Go to Top of Page

Michael71
Posting Yak Master

126 Posts

Posted - 2006-10-16 : 12:42:19
All I want to do is Sum up the monthlyExpenses and update the ytdExpenses everytime I submit data to the database.
Go to Top of Page

Michael71
Posting Yak Master

126 Posts

Posted - 2006-10-16 : 13:08:08
CAn anyone help me out Please
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-10-16 : 14:02:57
Close this topic and continue here http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=73584


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -