我希望ORDER BY
一个整数后跟一个字符串,但保持在一起并排序等于字符串。
示例:
[01] 01 | N9
[02] 02 | C4
[03] 03 | C5
[04] 04 | N9
[05] 07 | C5
[06] 08 | C5
[07] 15 | U1
[08] 15 | D2
[09] 16 | N9
[10] 18 | N9
所需订单:
[01] 01 | N9
[04] 04 | N9
[09] 16 | N9
[10] 18 | N9
[02] 02 | C4
[03] 03 | C5
[05] 07 | C5
[06] 08 | C5
[08] 15 | D2
[07] 15 | U1
我已尝试RANK
和ROW_NUMBER
,但我找不到正确的解决方案
答案 0 :(得分:1)
您似乎想要:
select e.*
from example e
order by min(col2) over (partition by col3), col3, col2;
答案 1 :(得分:1)
您也可以尝试
select * from <table> order by min(col2) over (partition by col3 order by col2)