SELECT TOP (20)percent count(*) FROM (SELECT [col1],col2
FROM [report].[detailsprovider]
WHERE [col3] = 2 group by [col1] as t order by t.col2
我正在努力做到这一点,但是按顺序被卡住了。
我想要col1的不同计数,排序前20%(基于col2)计数/行列表
答案 0 :(得分:0)
SELECT COUNT(*), col1
FROM (SELECT TOP 20 PERCENT col1 FROM myTable WHERE col3=2
ORDER BY col2) a
GROUP BY col1
注意:这适用于TSQL。我不确定其他SQL风格包含PERCENT