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

后端 未结 6 946
独厮守ぢ
独厮守ぢ 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:30

    group by does not order the data neccessarily. A DB is designed to grab the data as fast as possible and only sort if necessary.

    So add the order by if you need a guaranteed order.

提交回复
热议问题