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

Retrieve latest Rows in table

enter image description here

I want to get last updated status in this table..

what I want :

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

enter image description here

WHAT I TRIED

SELECT
  u1.NIC,
  u1.Status,
  u1.Remarks,
  u1.ADT
FROM callsc2 u1
  LEFT OUTER JOIN callsc2 u2
    ON u1.NIC = u2.NIC
    AND u1.ADT > u2.ADT

>Solution :

This can be done by joining your table with a dataset containing max ADT per status :

SELECT u.*
FROM callsc2 u
INNER JOIN (
  SELECT NIC, MAX(ADT) AS MAX_ADT
  FROM callsc2 
  GROUP BY NIC
) AS s on s.NIC = u.NIC AND s.MAX_ADT = u.ADT
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