Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How get first row from duplicate values mysql query

My table with value

id  ssid_no  end_date
1   5415345  18/12/2020
2   4656845  18/12/2020
3   8554511  01/05/2019

I want to make group but eliminite dublicate and select first id row.
in example eliminate after group select id=’1′ row(1,2 row have dublicate select first one) and id= ‘3’ row

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

SELECT * FROM (SELECT id, ssid_no, end_date, ROW_NUMBER() OVER (PARTITION BY ssid_no ORDER BY end_date) AS rownumber FROM ssid_no) t WHERE t.rownumber = 1;

This will return the first row for each id.👍

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading