I have following columns
+---------+----------+----------+
| Account | Employee | Org |
+---------+----------+----------+
| 123 | ABC | Gold |
| 234 | PQR | Silver |
| 456 | XYZ | |
| 567 | MNQ | Gold |
| 714 | RPT | Platinum |
| 819 | MKQ | BRONZE |
| 100 | LPA | Tin |
| 101 | QRT | |
| 104 | LMY | Platinum |
+---------+----------+----------+
Now the intention is to filter out all employees who have ORG like Bronze or Tin
Straight forward this is with query;
Select * from table 1 where Org NOT IN ('Bronze','Tin')
However this will filter records which have ORG as NULL which i don't want.
So basically above query gives me;
+---------+----------+----------+
| Account | Employee | Org |
+---------+----------+----------+
| 123 | ABC | Gold |
| 234 | PQR | Silver |
| 567 | MNQ | Gold |
| 714 | RPT | Platinum |
| 104 | LMY | Platinum |
+---------+----------+----------+
Where as i want;
+---------+----------+----------+
| Account | Employee | Org |
+---------+----------+----------+
| 123 | ABC | Gold |
| 234 | PQR | Silver |
| 456 | XYZ | |
| 567 | MNQ | Gold |
| 714 | RPT | Platinum |
| 101 | QRT | |
| 104 | LMY | Platinum |
+---------+----------+----------+
I could get this result by replacing NULL with some values with case statement and then filter records but i think there must be more clean and easy way of doing this?
My Current Query;
Select * from (
select ACCOUNT , EMPLOYEE ,
CASE WHEN ORG IS NULL THEN 'RETAIN'
ELSE ORG END AS EORG FROM table1 ) P
WHERE P.EORG not in ('Bronze','Tin')
Is there better way?