我有一张这样的桌子;
Product Price Type
-----------------------------------------
TV 10 T1
Computer 15 T1
Banana 2 T2
Apple 3 T2
我想对这两种不同的类型进行排序。 (MS-SQL)
Product Price Type
-----------------------------------------
TV 10 **T1**
Banana 2 **T2**
Computer 15 **T1**
Apple 3 **T2**
有没有办法做到这一点?
答案 0 :(得分:1)
您可以在ROW_NUMBER
子句中使用ORDER BY
:
SELECT *
FROM #tbl
ORDER BY
ROW_NUMBER() OVER(PARTITION BY Type ORDER BY Price),
Type