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
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