How do I have the last row displaying an aggregate function in Oracle SQL
Is it possible to display an aggregate function like avg on the last row as shown in the picture?
I also want the last row to be "------" if the row is empty. Note that the datatype of values in column A is numeric. (I am sorry if I made things wrong. I am new to StackOverflow)
[Here is how it should look like]
union all is the simplest method, but I would recommend just using
select a, b, c from t union all select '---', 'Average', avg(c) from t;
SQL does not guarantee the ordering of the rows, but in practice, the
avg() is usually last.