Jump to content

Recommended Posts

Posted


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!

 

Posted

Group by ID and max(date) .... 

 

mention the  database you are using .. 

Posted
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; 

 

Posted

Thanks bro below worked

select distinct ID, max(DateTime) from tablename group by id order by max(DateTime) desc, ID

Posted
20 minutes ago, LungiLingaraju said:

Group by ID and max(date) .... 

 

mention the  database you are using .. 

Sql. Thanks for your time bro

Posted
21 minutes ago, awaraa said:

distinct ids and max(datetime) cheyi 

Thanks bro

Posted
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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...