Quantcast
Channel: SQL Query to get latest records for that user - Stack Overflow
Viewing all articles
Browse latest Browse all 4

SQL Query to get latest records for that user

$
0
0

I have a MySQL database and I need a little help with querying the data from the table.

// Tableid              INTEGER,column1         VARCHAR,completiondate  DATETIME// Sample data(101, 'a', '2020-03-20 12:00:00')(101, 'b', '2020-03-21 12:00:00')(101, 'c', '2020-03-22 12:00:00')(101, 'c', '2020-03-23 12:00:00')(101, 'd', '2020-03-24 12:00:00')(102, 'a', '2020-03-20 12:00:00')(102, 'b', '2020-03-21 12:00:00')

Here, I want to view all the records for that specific user and display only the latest one from the duplicates found in column1.

Expected Output for user 101:

(101, 'a', '2020-03-20 12:00:00')(101, 'b', '2020-03-21 12:00:00')(101, 'c', '2020-03-23 12:00:00')(101, 'd', '2020-03-24 12:00:00')

I'm new with SQL. Would be great if anyone can provide any insight on this.

Thanks in advance!


Viewing all articles
Browse latest Browse all 4

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>