What can an aggregate function do in the ORDER BY clause?

前端 未结 3 1939
夕颜
夕颜 2020-12-31 08:45

Lets say I have a plant table:

id fruit
1  banana
2  apple
3  orange

I can do these

SELECT * FROM plant ORDER BY id;
SELECT         


        
3条回答
  •  时光说笑
    2020-12-31 09:05

    1. When you use an aggregate like that, the query gets an implicit group by where the entire result is a single group.

    2. Using an aggregate in order by is only useful if you also have a group by, so that you can have more than one row in the result.

提交回复
热议问题