When you select via SUM, the data returned is grouped into individual records, which is nice. The query below returns the sum correctly, but the values for adjacent columns always seem to be from the oldest record. Is there any way to control the order of adjacent columns? For example, return the sum and return the data for the latest row.
SELECT user_id, sale_date, SUM(totals) as total_sum WHERE user_id = 1
The following seems to have no effect. My guess is because the order is already determined and only 1 row is returned.
SELECT user_id, sale_date, SUM(totals) as total_sum WHERE user_id = 1 ORDER BY sale_date DESC
You are right, you only get one row, but you can always do this
Looks cleaner too