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!