Question:
My SQL statement at the moment is: SELECT * FROM NewsItems
How do I sort the dates in descending order?
Answer:
Use the ORDER BY clause to sort the results of a SELECT statement. The ORDER BY clause orders the results by the specified column. It sorts in ascending order by default, so you’ll have to specify descending order like this:SELECT * FROM NewsItemsORDER BY DateCol DESC
The DESC applies only to the column preceding it so you could order by date in descending order and by another column in ascending order.SELECT * FROM NewsItemsORDER BY DateCol DESC, AnotherCol ASC
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.
Related Posts
- Calix Announces AXOS???, the World???s Most Advanced Operating System for the SDN-enabled Access Network
- Behind the severe £11.5m pension fraud at Norton Motorcycles:
- Convert Your PDF Documents to Excel Spreadsheets in One Click
- Label Breakpoints in Visual Studio for Easy Access and Readability
- Open Source Group Protests Oracle’s Handling of Java EE























