Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement - NONNUMERICAL

Status
Not open for further replies.

citto

Technical User
May 12, 2006
1
US
I am trying to create a function that will give a certain rate for a particular job class. For example

if jobclass = 'J' then 20.00 else if jobclass = 'CJ' then 25.00 else if jobclass = 'A' then 18.00

etc...

I know if statements require a numerical value, but I don't know how to convert the jobclass to a number. Am I barking up the wrong tree?????
 
You could do it a few ways:

DECODE(jobclass,
'J',20.00,
'CJ',25.00,
'A',18.00,
0)

Or

case
when jobclass = 'J' then 20.00
when jobclass = 'CJ' then 25.00
when jobclass = 'A' then 18.00
else 0
end


CharlesCook.com
ADP - PeopleSoft - SAP
ReportSmith - Crystal Reports - SQR - Query - Access
Reporting - Interfaces - Data Mining
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top