1
SELECT TOP 1
        hol_id ,
        CONVERT(VARCHAR(12), hol_date, 112)
FROM    holiday
WHERE   hol_id = 5
UNION ALL
SELECT  hol_id ,
        CONVERT(VARCHAR(12), hol_date, 112)
FROM    holiday
WHERE   hol_id <> 5
ORDER BY CONVERT(VARCHAR(12), hol_date, 112) DESC

そうですか

1   20131218
5   20131018
6   20130818
3   20130405
4   20130311
2   20121129

見たい

5   20131018
1   20131218
6   20130818
3   20130405
4   20130311
2   20121129
4

2 に答える 2

0

次のように、特定のレコードを一番上に移動する新しい値を計算します。

order by
      case when hol_id = 5 then 0 else 1 end -- Sort hol_id 5 at the top
    , hol_date desc -- Sort the rest according to date
于 2013-04-15T16:35:19.580 に答える