Does “group by” automatically guarantee “order by”?

后端 未结 6 943
独厮守ぢ
独厮守ぢ 2021-02-12 16:57

Does \"group by\" clause automatically guarantee that the results will be ordered by that key? In other words, is it enough to write:

select * 
from table
group          


        
6条回答
  •  粉色の甜心
    2021-02-12 17:20

    It depends on the database vendor.

    For example PostgreSQL does not automatically sort the grouped result. Here you have to use order by to get the data sorted.

    But Sybase and Microsoft SQL Server do. Here you can use order by to change the default sorting.

提交回复
热议问题