| Author |
Topic |
|
blocker
Yak Posting Veteran
89 Posts |
Posted - 2010-03-18 : 05:44:24
|
| HI guys.I just want to ask a litle help on how to sum up all speficied field values base on specified date range.Thank you guys for giving your idea and time. |
|
|
haroon2k9
Constraint Violating Yak Guru
328 Posts |
Posted - 2010-03-18 : 06:03:24
|
quote: Originally posted by blocker HI guys.I just want to ask a litle help on how to sum up all speficied field values base on specified date range.Thank you guys for giving your idea and time.
Could you please provide some sample data and expected output |
 |
|
|
blocker
Yak Posting Veteran
89 Posts |
Posted - 2010-03-18 : 21:25:10
|
| i need to sum up all number values in a field named amount(as money) depending on a specified date range in product_tbl via a stored procedure and call it in t-sql query.can this be possible.? Thanks for any ideas. God bless. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-18 : 21:43:58
|
it will be easier for us to help you if you can provide the table structure, sample data and required result. KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
blocker
Yak Posting Veteran
89 Posts |
Posted - 2010-03-19 : 09:14:29
|
| Assuming that product_tbl has a field named totalamount(as money), totalamount holds numbers only. I want to get the sum of all amounts in totalamount field and store it in totalamt variable. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-19 : 09:29:25
|
[code]select @totalamt = sum(totalamount)from product_tbl[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
blocker
Yak Posting Veteran
89 Posts |
Posted - 2010-03-22 : 03:50:04
|
| thank you.but how about showing tha totalamount based on given fromdate and todate.? ex. the user wants to show the totalamount from 03/22/2010 to 03/25/2010?thank you for giving time 7 God bless. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-22 : 05:19:12
|
[code]declare @fromdate datetime, @todate datetimeselect @fromdate = '20100322', @todate = '20100325'select @totalamt = sum(totalamount)from product_tblwhere datecol >= @fromdateand datecol <= @todate[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
blocker
Yak Posting Veteran
89 Posts |
Posted - 2010-03-22 : 05:31:45
|
| thank you very much.. God bless us all. |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-03-22 : 05:37:50
|
amen KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
blocker
Yak Posting Veteran
89 Posts |
Posted - 2010-03-22 : 05:38:35
|
| ..haha |
 |
|
|
|