What is the purpose of Order By 1 in SQL select statement?

后端 未结 8 1239
醉酒成梦
醉酒成梦 2020-12-12 19:43

I\'m reading through some old code at work, and have noticed that there are several views with an order by 1 clause. What does this accomplish?

Exampl

8条回答
  •  死守一世寂寞
    2020-12-12 20:24

    This is useful when you use set based operators e.g. union

    select cola
      from tablea
    union
    select colb
      from tableb
    order by 1;
    

提交回复
热议问题