After combining several SELECT queries, I can't get ORDER BY to return a result for the highest price in each group
If I add ORDER BY to the end, it shows the results of the tables IN ORDER - I want to return the highest value for each SELECT query. I've tried using UNION ALL between the SELECT's. Also tried adding an ORDER BY to each query (to SELECT each highest value), which doesn't work at all.
SELECT TOP 1 cost_per_unit, season
FROM fruit_imports
WHERE season != 'All Year'
AND season = 'Winter'
UNION
SELECT TOP 1 cost_per_unit, season
FROM fruit_imports
WHERE season != 'All Year'
AND season = 'Spring'
UNION
SELECT TOP 1 cost_per_unit, season
FROM fruit_imports
WHERE season != 'All Year'
AND season = 'Summer'
UNION
SELECT TOP 1 cost_per_unit, season
FROM fruit_imports
WHERE season != 'All Year'
AND season = 'Fall'
ORDER BY cost_per_unit DESC
Incorrect syntax near the keyword 'UNION'. is one message I get when using multiple ORDER BY statements. If I use ORDER BY in the 4th SELECT, the result is:
0.22 Winter
0.15 Spring
0.12 Fall
0.02 Summer
The result I want is like:
0.22 Winter
0.60 Spring
0.35 Fall
0.68 Summer