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 |
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2008-04-18 : 14:47:28
|
| I found this if statement in one of my reports, but it is not working do I have the statement setup wrong?if TATDay <= .166 then "A: < 4 Hours"elseif TATDays > .166 and TATDays <= .5 then "B: 4 to 12 hours"elseif TATDays > .5 and TATDays <= 1 then "C: 13 to 24 Hours"elseif TATDays > 1 and TATDays <= 3 then "D: Greater than 1 day to 3 Days"elseif TATDays > 3 and TATDays <= 5 then "E: Greater than 3 days to 5 Days"elseif TATDays > 5 and TATDays <= 10 then "F: Greater than 5 days to 10 Days"elseif TATDays > 10 then "G: Greater than 10 Days"End |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-18 : 15:01:28
|
| Is the field name TATDay or TATDays? you've used former in one place and latter in others. ALso wats the error you're getting? |
 |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2008-04-18 : 15:09:45
|
It's TATDaysHere is the Error...Msg 156, Level 15, State 1, Line 7Incorrect syntax near the keyword 'if'.Msg 156, Level 15, State 1, Line 7Incorrect syntax near the keyword 'then'.quote: Originally posted by visakh16 Is the field name TATDay or TATDays? you've used former in one place and latter in others. ALso wats the error you're getting?
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-04-18 : 15:11:35
|
| You dont need the then and else. remove all of them and try |
 |
|
|
werhardt
Constraint Violating Yak Guru
270 Posts |
Posted - 2008-04-18 : 15:23:57
|
| ok, Here it is now. I am a little confused, now there was an error Incorrect syntax near the keyword 'if'.if TATDays <= .166 as "A: < 4 Hours"if TATDays > .166 and TATDays <= .5 as "B: 4 to 12 hours"if TATDays > .5 and TATDays <= 1 as "C: 13 to 24 Hours"if TATDays > 1 and TATDays <= 3 as "D: Greater than 1 day to 3 Days"if TATDays > 3 and TATDays <= 5 as "E: Greater than 3 days to 5 Days"if TATDays > 5 and TATDays <= 10 as "F: Greater than 5 days to 10 Days"if TATDays > 10 then "G: Greater than 10 Days"End |
 |
|
|
gayoosoftware
Starting Member
8 Posts |
Posted - 2008-04-21 : 00:09:10
|
| i think you are trying to return text. so dont use "AS" use "print"like this,if TATDays <= .166 print "A: < 4 Hours"if TATDays > .166 and TATDays <= .5 print "B: 4 to 12 hours"if TATDays > .5 and TATDays <= 1 print "C: 13 to 24 Hours"if TATDays > 1 and TATDays <= 3 print "D: Greater than 1 day to 3 Days"if TATDays > 3 and TATDays <= 5 print "E: Greater than 3 days to 5 Days"if TATDays > 5 and TATDays <= 10 print "F: Greater than 5 days to 10 Days"if TATDays > 10 print "G: Greater than 10 Days" |
 |
|
|
|
|
|