Max Date Last Update Date SQL

Viewed 23

I am asking for help with this item. I am a novice to SQL and not very sure how to handle this problem I appreciate any help from the forum.

I have a table that is updated multiple times a day. I would like to create a view that only displays the last update that was made for a given day.

Here is a sample of the data

enter image description here

This is the desired result of the SQL Query when the data set provided has been queries

enter image description here

2 Answers

As I understood you want to get the last record of every day.

Just group it by day

You will have to use EXTRACT to do it

Example: EXTRACT(DAY FROM DATE)

Then select the max time from the column where you have the time of the day. If you dont have the time in a different column you will also need to extract it.

SELECT MAX(TIME_COLUMN) FROM `TABLE_NAME`
GROUP BY EXTRACT(DAY FROM DATE)

SELECT MAX (your_date) AS "Max Date" FROM your_table

Related