SQLDev限制结果

时间:2012-11-11 15:54:55

标签: oracle-sqldeveloper

任何帮助/建议/进一步阅读的TIA。

我正在尝试让SQLDev计算客户拥有的软件包数量,然后只显示这些结果中的前10名。

所以我有这个......

    select  pickup_customer , count (pickup_customer)
from 
( select pickup_customer, count (pickup_customer)
    from manifest
   order by count (pickup_customer) desc ) 
 where ROWNUM <= 10
 group by pickup_customer
 order by count (pickup_customer) desc

由此我得到'不是单一的群体功能',我无法弄清楚它出了什么问题。可能非常简单的修复,我现在看不到它!

编辑:我已经尝试过这段代码,但现在却出现了'错过右括号'的错误!

select  pickup_customer , count (pickup_customer)
from 
(select pickup_customer, count (pickup_customer) --sub-query which pre-orders the results for rownum to then limit.
    from manifest
   order by count (pickup_customer) desc 
   group by pickup_customer)
 where ROWNUM <= 10    -- limits the results to be only the top 10

1 个答案:

答案 0 :(得分:2)

以下查询应该有效。

SELECT pickup_customer, COUNT (pickup_customer)
FROM enrollment
WHERE ROWNUM <= 10
GROUP BY pickup_customer
ORDER BY COUNT (pickup_customer) DESC