The data is as follows and each cust_id (customer id) may or may not have multiple rows of data. Just as a sample data I have created the following. I want to write a SQL query to get all the data of each cust_id (customer id) where the timestamp is latest.
A canonical method is:
select te.* from time_entry te where te.visit_date = (select max(te2.visit_date) from time_entry te2 where te2.cust_id = te.cust_id );
2.1m questions
2.1m answers
60 comments
57.0k users