RockyBhai Posted June 30, 2020 Report Posted June 30, 2020 I have Sno, ID, DateTime, X, Y, Z Columns in my table. Sno is unique and ID column will have duplicates. I want to query all Distinct ID’s with latest DateTime. Appreciate your help! Quote
LungiLingaraju Posted June 30, 2020 Report Posted June 30, 2020 Group by ID and max(date) .... mention the database you are using .. Quote
Spartan Posted June 30, 2020 Report Posted June 30, 2020 6 minutes ago, RockyBhai said: I have Sno, ID, DateTime, X, Y, Z Columns in my table. Sno is unique and ID column will have duplicates. I want to query all Distinct ID’s with latest DateTime. Appreciate your help! https://www.w3schools.com/sql/sql_distinct.asp SELECT DISTINCT column1, column2, ... FROM table_name; SELECT DISTINCT column1, column2, ... FROM table_name; Quote
RockyBhai Posted June 30, 2020 Author Report Posted June 30, 2020 Thanks bro below worked select distinct ID, max(DateTime) from tablename group by id order by max(DateTime) desc, ID Quote
RockyBhai Posted June 30, 2020 Author Report Posted June 30, 2020 20 minutes ago, LungiLingaraju said: Group by ID and max(date) .... mention the database you are using .. Sql. Thanks for your time bro Quote
RockyBhai Posted June 30, 2020 Author Report Posted June 30, 2020 21 minutes ago, awaraa said: distinct ids and max(datetime) cheyi Thanks bro Quote
Picheshwar Posted June 30, 2020 Report Posted June 30, 2020 22 minutes ago, RockyBhai said: Thanks bro below worked select distinct ID, max(DateTime) from tablename group by id order by max(DateTime) desc, ID group by vadutunnav.. dISTINCT endhuku bokka Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.