|
没有排名函数,蛋疼
[code=sql]SELECT A.*,
(
SELECT COUNT(1) FROM
(
SELECT PCAT, ITEM_BRANDTEXT, ITEM_MODELTEXT, REGION2, SUM([201301M]) AS [201301M_SUM]
FROM 数据源
GROUP BY PCAT, ITEM_BRANDTEXT, ITEM_MODELTEXT, REGION2
) WHERE REGION2=A.REGION2 AND [201301M_SUM]>=A.[201301M_SUM]
) AS RANKS
FROM
(
SELECT PCAT, ITEM_BRANDTEXT, ITEM_MODELTEXT, REGION2, SUM([201301M]) AS [201301M_SUM]
FROM 数据源
GROUP BY PCAT, ITEM_BRANDTEXT, ITEM_MODELTEXT, REGION2
) AS A
WHERE
(
SELECT COUNT(1) FROM
(
SELECT PCAT, ITEM_BRANDTEXT, ITEM_MODELTEXT, REGION2, SUM([201301M]) AS [201301M_SUM]
FROM 数据源
GROUP BY PCAT, ITEM_BRANDTEXT, ITEM_MODELTEXT, REGION2
)
WHERE REGION2=A.REGION2 AND [201301M_SUM]>=A.[201301M_SUM]
)<=15[/code] |
|