我有一个查询
select sum(pur.purchase_net_invoice_value), par.party_desc from purchase pur
join party par
on par.party_id = pur.party_id
group by par.party_desc;
运行良好。
我只想让 查询的前五行 并丢弃其他行。
最佳答案
您可以为此使用 rownum
pseduocolumn:
SELECT *
FROM (SELECT SUM(pur.purchase_net_invoice_value), par.party_desc
FROM purchase pur
JOIN party par ON par.party_id = pur.party_id
GROUP BY par.party_desc
ORDER BY 1 DESC)
WHERE rownum <= 5;
关于sql - 从 sqlplus 查询中选择顶行,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/23308638/