mysqldistinct-valuessqlfiddle

MySQL- How to select distinct data against a same record


Referring to the question asked. I have a table which includes multiple records for the same entry like below image

enter image description here

All I want is to select the single record against each entry. I have also set the DB and Query in DB Fiddle

Any help would be highly appreciated.


Solution

  • From discussion got you need convert datetime to date and group by clause column to date

    for your table

    SELECT  p.`zdjh` AS MSN, max(p.`sjsj`) AS Date_Time,max( p.`xhqd`) AS Ping 
    FROM `tj_xhqd` p
    WHERE p.`sjsj` <='2018-07-24 10:15:00' AND p.`sjsj` >='2018-07-23 10:15:00'
    group by zdjh
    ORDER BY MSN, Date_Time, Ping DESC