Skip to content
Advertisement

Need a Query to fetch distinct data from a table in my sql

I have a table History which contains below columns:

I need a query to fetch data from a table in a manner that every user should return only one row for the day even if a user has more than one entry for a day

The required resultset should be as below :

Advertisement

Answer

You can group by User and date and get the minimum createdOn for each user:

See the demo.
Results:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement