Re: How To select many fields by DISTINCT one field ?
I'm sure you have some idea of what you mean, but it isn't clear to us (with this kind of question, there are hundreds of variations of what people mean)
Assuming data like the following:
Code:
Name Telephone City Job
Joe 234 London Baker
John 1321 London Builder
Dave 3165 London Soldier
Eric 456 Liverpool Baker
Tom 4546 Liverpool Pilot
Please show us how you want this data displayed (and preferably explain why the output is as you show).
Re: How To select many fields by DISTINCT one field ?
I got it
I can use DISTICNT only for one field if use it without another field
but if i want to use it with many fields i will use it with group by example
Re: How To select many fields by DISTINCT one field ?
Hello,@nader
Please try this code, How To select many fields by DISTINCT one field ?
Code:
SELECT * FROM
GPSReport AS G1
JOIN (SELECT device_serial, max(datetime) as mostrecent
FROM GPSReport group by device_serial) AS G2
ON G2.device_serial = G1.device_serial and g2.mostrecent = g1.datetime
ORDER BY G1.device_serial