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 |
JAdauto
Posting Yak Master
160 Posts |
Posted - 2004-05-03 : 22:06:49
|
I need to pass a parameter value for the month the user wants to report on. These parameters are all numeric. So, it would be 1 for January, 2 for February, etc. But the fields in our table are named 'January', 'February', etc and are bit fields. (Fields for all 12 months and true if they are to be charged that month)I wrote something like this:Select *,CASE @MonthNumberWHEN 1 THEN 'January'WHEN 2 THEN 'February'WHEN 3 THEN 'March'WHEN 4 then 'April'End as MonthNameFROM ChargesWHERE MonthName = 1This is certainly not working because Monthname is not a column name. I was just wondering if there was a way to accomplish this with our numeric parameter.Thanks again,JAdauto |
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-05-03 : 22:27:54
|
select * from tbl where @MonthNumber = 1 and January = 1unionselect * from tbl where @MonthNumber = 2 and February = 1union...then join to that.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
cinrain
Starting Member
1 Post |
Posted - 2004-05-04 : 12:07:04
|
strange table structure. why set 12 fields for month flag,there must be a special request... |
 |
|
|
|
|