How can I make it get results ordered numerically, descending?
Briefly

The SQL query intended to export data from a MySQL table into a CSV file is encountering issues with the sorting of results. While the query attempts to use UNION to combine a static label with actual data from the 'tbl_nr_access' table, it fails to order the 'nr_access' column correctly. The current approach with CASE and UNION is causing the unintended output order. A more straightforward SELECT statement with an ORDER BY clause is needed to retrieve the data in the desired descending order of the 'nr_access' values without unnecessary complexity.
In your SQL query, you are attempting to select and export the 'nr_access' data in descending order, but the implementation is incorrect, leading to unsorted output.
Your use of the UNION operator is not resulting in the desired output because of how the orders and selections are structured. The output needs a different approach to achieve the correct sorting.
Read at SitePoint Forums | Web Development & Design Community
[
|
]