我有一個Case
語句,它將給出範圍值。我需要的結果範圍明智的順序進行相應的設置進行排序:Oracle SQL中的排序範圍值
select distinct CASE
when Table__107.Column <= 30 then
'0-30'
when (Table__107.Column >= 31 and
Table__107.Column <= 60) then
'31-60'
when (Table__107.Column >= 61 and
Table__107.Column <= 90) then
'61-90'
when (Table__107.Column >= 91 and
Table__107.Column <= 120) then
'91-120'
when (Table__107.Column >= 121 and
Table__107.Column <= 180) then
'121-180'
when (Table__107.Column >= 181 and
Table__107.Column <= 365) then
'181-365'
when Table__107.Column > 365 then
'365+'
end as Column
我所需的輸出是
0-30
31-60
61-90
.....
.....
365+
標誌
我嘗試使用Order by 1
和Order By ASC
,但它是基於第一劃分字符字母數字不是數字值的範圍。
我試過使用Order BY 1和Order By ASC,但它是基於第一個字符進行排序的。 – user1838000