So I'm writing a PHP script that takes out the duplicate entries of this SQL query:
SQL:
SELECT DISTINCT a.pname, a.pnumber, a.plocation,
CASE WHEN a.plocation = b.dlocation then 'Local'
ELSE 'Remote'
END AS ptype
FROM PROJECT a LEFT JOIN DEPT_LOCATIONS b on a.dnum = b.dnumber
order by a.pnumber;
Output:
PNAME PNUMBER PLOCATION PTYPE
--------------- ---------- --------------- ------
ProductX 1 Bellaire Local
ProductX 1 Bellaire Remote
ProductY 2 Sugarland Local
ProductY 2 Sugarland Remote
ProductZ 3 Houston Local
ProductZ 3 Houston Remote
Computerization 10 Stafford Local
Reorganization 20 Houston Local
Newbenefits 30 Bellaire Remote
Virtualization 40 Houston Local
Virtualization 40 Houston Remote
CRM 50 Stafford Local
Bladeservers 60 Houston Local
The problem is sometime the results show both Local and Remote. I want it so that if there is a Local, the Remote wouldn't show. Is that a possibility in SQL or do I have to do that in PHP?