There are two tables EMPLOYEES and EMPLOYEE_PAN. We have to print employee NAME from EMPLOYEES table and UIN from EMPLOYEE_PAN table. ID is in both the tables used as a primary key. If no UIN is present in EMPLOYEE_PAN table then we have to print NULL instead of UIN. UIN is an integer.
I have tried this code. I am facing an error in the case when statement part. I am facing a problem in case statements when JOIN is used in the query. Please let me know how to use CASE statement with JOIN.
SELECT UIN, NAME
FROM EMPLOYEE_PAN JOIN EMPLOYEES
ON EMPLOYEES.ID = EMPLOYEE_PAN.ID
CASE WHEN EMPLOYEE_PAN.UIN != 0 THEN EMPLOYEE_PAN.UIN END ;