Case statement

mg2rde

Registered User.
Local time
Today, 14:19
Joined
Jun 28, 2011
Messages
11
To all,

I need help with the following:

I am writing a pass-thru query and need to write a complex case statment (for me anyway)

if total hours is equal or less than 15 then LEVEL1
if total hours is greater then 15 then level1 is 15-1
and level2 is total hours -15


any help will be appreciated
 
To all,

I need help with the following:

I am writing a pass-thru query and need to write a complex case statment (for me anyway)

if total hours is equal or less than 15 then LEVEL1
if total hours is greater then 15 then level1 is 15-1
and level2 is total hours -15


any help will be appreciated

SELECT (some stuff),
TotalHoursLevel = CASE WHEN TotalHours <= 15 THEN 'Level1',
WHEN TotalHours > 15 THEN '15-1'

END,
Level2 = TotalHours - 15, (if I understand what you mean)
(select more stuff)
FROM SomeDamedTable
WHERE SomeStuffIsTrue
 
thank you very much bparkinson, you are awesome:D
 
To all,

I need to change level2 a bit... the original is below...now i need level2 to be greater than 15 hours and then minus 15 from totalhours

so do I have to insert another case statement.....


thanks in advance...

SELECT (some stuff),
TotalHoursLevel = CASE WHEN TotalHours <= 15 THEN 'Level1',
WHEN TotalHours > 15 THEN '15-1'

END,
Level2 = TotalHours - 15, (if I understand what you mean)
(select more stuff)
FROM SomeDamedTable
WHERE SomeStuffIsTrue
 

Users who are viewing this thread

Back
Top Bottom