Jump to content

Sql Help Please


RockyBhai

Recommended Posts


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!

 

Link to comment
Share on other sites

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; 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...