I have a issue with some SQL that I can't wrap my head around a solution.
Right now the query I am running basically is:
SELECT Q.ID, Q.STATUS, C.LASTNAME, C.FIRSTNAME,
C.POSTAL, C.PHONE
FROM QUEUE Q
LEFT OUTER JOIN CUSTOMER C ON Q.ID = C.APPID
WHERE C.LASTNAME LIKE 'SMITH%'
I have about 200 records from this query. My issue is the same person has multiple occurances.
Q.ID Q.STATUS C.LASTNAME C.FIRSTNAME ETC...
1 A SMITH JOHN
2 A SMITH RYAN
3 B SMITH BRIAN
100 A SMITH RYAN
200 A SMITH RYAN
What I need returned instead is
Q.ID Q.STATUS C.LASTNAME C.FIRSTNAME ETC...
1 A SMITH JOHN
3 B SMITH BRIAN
200 A SMITH RYAN
Can anyone point me in the right direction please. I have tried
SELECT WHATEVER FROM TABLE WHERE Q.ID IN (SELECT MAX(ID) FROM TABLE WHERE BLAH BLAH)
which worked when searching for "RYAN SMITH" specifically. But I need to show all results for SMITH with the highest IDs.
Any help is appreciated.
Cheers