SQL: Using Top 1 in UNION query with Order By

后端 未结 4 1265
遇见更好的自我
遇见更好的自我 2021-01-03 22:59

I have a table as below

Rate Effective_Date
---- --------------
5.6  02/02/2009
5.8  05/01/2009
5.4  06/01/2009
5.8  12/01/2009
6.0  03/15/2009
4条回答
  •  Happy的楠姐
    2021-01-03 23:16

    The Order By in a select statement that is part of a union is ignored. Hence your TOP 1 is selecting some arbitary record (likely the first record by the clustered key for the table).

提交回复
热议问题