Hello everyone, i'm using oracle 21C xe.
I want list the total of cases of wine sold by wine types in alphabetical order, and them have a grand total cases sold for all wine.
I use this code which unions a GROUP BY query with a query that generates the total, I can not put ORDER BY after the first set, which causes error, so I put at the end.
SELECT wine, sum(cases_sold) FROM ws
join wines
on ws.wine_id = wines.wine_id
group by wine
union
select 'Total', sum(cases_sold) from ws
order by wine;

The result output is thet Total is not the final row because there is a wine (Vilana) that ranked alphabetically after Total.
How can write a query that would ensure that Total query row is the last row while keep first set in an alphabetical order?
thanks.