|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
不支持SQL Server排名函数就是麻烦:- SELECT P1.编号,P3.编号 FROM
- (SELECT TOP 3 T1.编号 FROM [Sheet1$A:C]T1
- LEFT JOIN
- (SELECT A.编号,SUM(1) AS 排序 FROM
- (SELECT top 3 编号,Second(NOW())*1000 MOD RIGHT(编号,2)&编号 AS 辅助 FROM [Sheet1$A:C]WHERE 甲='YES' ORDER BY 2)A,
- (SELECT top 3 编号,Second(NOW())*1000 MOD RIGHT(编号,2)&编号 AS 辅助 FROM [Sheet1$A:C]WHERE 甲='YES' ORDER BY 2)B
- WHERE A.辅助>=B.辅助
- GROUP BY A.编号)T2
- ON T1.编号=T2.编号
- WHERE T2.编号 IS NULL)P1,
- (SELECT TOP 3 T1.编号 FROM [Sheet1$A:C]T1
- LEFT JOIN
- (SELECT A.编号,SUM(1) AS 排序 FROM
- (SELECT top 3 编号,Second(NOW())*1000 MOD RIGHT(编号,2)&编号 AS 辅助 FROM [Sheet1$A:C]WHERE 甲='YES' ORDER BY 2)A,
- (SELECT top 3 编号,Second(NOW())*1000 MOD RIGHT(编号,2)&编号 AS 辅助 FROM [Sheet1$A:C]WHERE 甲='YES' ORDER BY 2)B
- WHERE A.辅助>=B.辅助
- GROUP BY A.编号)T2
- ON T1.编号=T2.编号
- WHERE T2.编号 IS NULL)P2,
- (SELECT A.编号,SUM(1) AS 排序 FROM
- (SELECT top 3 编号,Second(NOW())*1000 MOD RIGHT(编号,2)&编号 AS 辅助 FROM [Sheet1$A:C]WHERE 甲='YES' ORDER BY 2)A,
- (SELECT top 3 编号,Second(NOW())*1000 MOD RIGHT(编号,2)&编号 AS 辅助 FROM [Sheet1$A:C]WHERE 甲='YES' ORDER BY 2)B
- WHERE A.辅助>=B.辅助
- GROUP BY A.编号)P3
- WHERE P1.编号>=P2.编号
- GROUP BY P1.编号,P3.编号,P3.排序
- HAVING P3.排序=SUM(1)
复制代码 |
评分
-
1
查看全部评分
-
|