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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help with select statement

Status
Not open for further replies.

sql99

Programmer
Nov 12, 2003
83
US
Hello everyone,

I have the following select statement"

(SELECT pers.pers_no pers_id,
MAX(decode(substr(TRIM(pers.pers_job), 1, 5), 'SALES', pers.annual_salary)) sales_sal,
MAX(decode(TRIM(pers.pers_job), 'RECEPTIONIST', pers.annual_salary)) recep_sal,
MAX(decode(TRIM(pers.pers_job), 'CLERK', pers.annual_salary)) clerk_sal
FROM PERSON pers, STATUS stat
WHERE pers.pers_id = stat.pers_id
AND pers.pers_status = 'ACTIVE'
AND pers.job_status = 'ACTIVE')

Can someone help me with the first decode? Since there are various types of SALES category like sales1, sales2, sales3, etc...I would like for whichever one to be active to have the salary shown under "sales_sal". For example, employee 123 has a pers_job of sales1 up to sales4 but only sales2 is active...then I would like the "sales_sal" to only show the salary for sales2 which is active and disregard the other sales...I don't want to list each sales category down and have many sales salary columns.

Thanks in advance,
sql99
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top