I have this query -
SELECT d.sn,d.alias,d.CompanyID,max(checkdate),checkin
FROM tbl_checkin ch
right join tbl_device d
on ch.sn=d.sn
group by ch.sn
order by max(checkdate) desc
these selects random checkin when runned
but what i want to acheive is a query where by its going to select the checkin based on the max(checkdate)
that is display the checkin that corresponds to the max(checkdate)
sn alias compid max(checkdate) checkin
4223642350043 DANTATA-SAWOE_1 1057 2014-06-05 14:10:01
4223642350051 DANTATA-SAWOE_2 1057 2014-05-28 17:04:46
4223642350067 DANTATA-SAWOE_3A 1057 2014-05-13 15:50:44
0278135000136 DANTATA-SAWOE_4 1057 null null
i'll be very grateful if i can get an answer