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 |
|
gavakie
Posting Yak Master
221 Posts |
Posted - 2008-01-25 : 17:31:05
|
| I have this code and it should bring back code for the month i put in in the set statement. When i put in say may i need to add up numbers for all months prior in the total projections call em and im lost Declare @Division as Varchar(15)Declare @Date as Varchar(7)Set @Division = 'Del Sol'Set @Date = '05/2008'Select [Month], Sum(Projection) as ProjectionTotalFrom Reporting.dbo.RetailSalesComparison_ProjectionsView PV Inner Join DelsolNet2.dbo.StoreGroup SG on PV.StoreID = OrderStoreIDWhere @Division = Case DivisionID When 10 then 'Del Sol' When 11 then 'Cariloha' When 12 then 'Sol Kids' else 'Notta' End and Month([Month]) = Left(@Date,2) and Year([Month]) = Right(@Date,4) Group By [Month] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-25 : 23:00:29
|
| Didnt understand you fully. Guess you want all data until month selected then for the year. Then use this.and Month([Month]) <= Left(@Date,2) and Year([Month]) = Right(@Date,4) |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-28 : 01:11:32
|
| Also use proper DATETIME parameter and dont handle dates as varcharsMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|