Solved SQL to sort DATE & TIME

April 13, 2016 at 08:46:11
Specs: Windows 7
Hello Hi,

I have three column in a Table as follows Name, Date, Time. Need a SQL to take the latest date & time for the unique name.

For Instance
Name Date Time
Jith 1-Dec-15 12:46 PM
Jith 2-Dec-15 3:46 PM
Jith 3-Dec-15 2:20 AM
Jith 3-Dec-15 1:46 AM

Final output should be Jith 3-Dec-15 2:20 AM.

When i was using MAX function of Date & Time separately output was Jith 3-Dec-15 12:46PM.

Please help in creating SQL, to sort DATE&TIME together and take the MAX date&time.

Thank you in advance.

Regards
Jith


See More: SQL to sort DATE & TIME

Report •


✔ Best Answer
April 14, 2016 at 01:25:08
You should be able to do something like:

SELECT * FROM (SELECT * ...) WHERE ...



#1
April 13, 2016 at 09:26:15
Redefine your database so that the date and time are stored in a single field.

Report •

#2
April 13, 2016 at 21:43:53
Hi,

Thank you for your reply. Database i am receiving from system. In that system by default it gives date and time in two separate column.


Report •

#3
April 14, 2016 at 00:38:46
In that case use a SELECT statement to produce a temporary table containing all records from the maximum date, then a second SELECT statement to find the record in that table with the maximum time.

Report •

Related Solutions

#4
April 14, 2016 at 01:23:13
Thank you so much.

It works fine..

Still is there any option to take in one short.


Report •

#5
April 14, 2016 at 01:25:08
✔ Best Answer
You should be able to do something like:

SELECT * FROM (SELECT * ...) WHERE ...


Report •


Ask Question