带百分位数问题的SQL自定义排序顺序

时间:2019-06-20 20:44:02

标签: sql-server

我有一个大约有60万条记录的表,我需要对ID键执行自定义顺序的百分位数。密钥不是唯一的,因为它们标记为TMC_CODE,其中详细说明了高速公路的设定长度。对于这600,000条记录,我大约有36个TMC,因为我希望SQL Server以非字母或数字的自定义顺序输出TMC。到目前为止,我的代码是:

WITH PERCENTILES AS (SELECT TMC_code, EPOCH, percentile_CONT(.98)  
WITHIN GROUP (ORDER BY cast(speed as float)) OVER (PARTITION BY TMC_code) AS TTAV_P_98 FROM [dbo].[I40]

SELECT TMC_code, TTAV_P_98 FROM Percentiles
GROUP BY TMC_code, TTAV_P_98 ORDER BY *no idea what to put here*

问题在于TMC的名称不是字母或数字。示例TMC是113 + 04489或113P04489或113N04489。

0 个答案:

没有答案