Sliding certain records to the end of a run of the same date

前端 未结 3 1998
名媛妹妹
名媛妹妹 2021-01-26 10:59

I have three columns -

  • TheDate - Obviously a date.
  • TheID - A strictly increasing ID.
  • TheType - A Record t
3条回答
  •  [愿得一人]
    2021-01-26 11:33

    If TheID cannot be null then just change the TheID to null as part of the order by where TheType is a special value:

    order by TheDate, 
             case TheType
               when 101 then null
               else TheID
             end nulls last
    

提交回复
热议问题