I’m having an issue using ORDER BY in my SQL code. This SQL code is contained in a Power Table. My intention is to return the values in order of the record date descending, however once I add this line to the code it results in an error.
Please view my code below and if anybody could help it would be great.
Many thanks,
Cathal.
(Working Block of Code Above)
UNION
SELECT
record_date,
data1,
data2,
data3,
data4,
data5,
data6
FROM daily_totals_kwh
WHERE record_date BETWEEN ‘{SQL/5DaysAgo}’ AND ‘{SQL/now}’
Many thanks for your response. The block runs successfully on its own, however I require the information to be presented in the opposite order from how it is currently presenting itself.
Do you know how this could be done?
Select * from (
(Working Block of Code Above)
UNION
SELECT
record_date,
data1,
data2,
data3,
data4,
data5,
data6
FROM daily_totals_kwh
WHERE record_date BETWEEN ‘{SQL/5DaysAgo}’ AND ‘{SQL/now}’
UNION
(Working Block of Code Below)
) unionedData
order by record_date desc