Wednesday, January 20, 2016

SQL ORDER BY: Display Records in According to Date and Time in Descending Order

ORDER BY is the keyword used to arrange records either in ascending (which is the default ordering if not set) or descending order.

If you are going to arrange the records in a certain table by date and time, make sure that you use the 24 hour format to avoid unexpected results.

Table: 










Query:
select * from post order by date_posted desc,time_posted desc

The code above will first arrange the record in descending order according to the date_posted and then followed by time_posted also in descending order. For multiple columns, you need to put a comma(,) as a separator between columns.

Output:

SQL ORDER BY: Display Records in According to Date and Time in Descending Order

SQL ORDER BY: Display Records in According to Date and Time in Descending Order Rating: 4.5 Diposkan Oleh: Emoblazz

0 comments:

Post a Comment