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.
| Author |
Topic |
|
raihan26
Starting Member
8 Posts |
Posted - 2011-03-17 : 17:33:51
|
Is there any way that we can calculate the sum of amount in every category in particular month. Like the way it is show in an image just an example. As I was trying to do with this query but it was not working. Any suggestion will be appreciated."SELECT category, SUM(amount) AS OrderTotal FROM budget1 WHERE month='January' " And I want to do something like this. Any suggestions will be appreciated. |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-03-17 : 17:38:30
|
| SELECT Month, category, SUM(amount) AS OrderTotal FROM budget1 GROUP BY Month, categoryORDER BY Month, category |
 |
|
|
raihan26
Starting Member
8 Posts |
Posted - 2011-03-17 : 18:07:04
|
I have updated the image. What I want is that when I pass month parameter in where clause then it will sum the amount of those category that belong to month in the table. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-03-17 : 18:14:18
|
| CREATE PROCEDURE MonthlySummary @month varchar(15) ASSET NOCOUNT ONSELECT category, SUM(amount) AS OrderTotal FROM budget1 WHERE month=@monthGROUP BY Category |
 |
|
|
|
|
|