我有一个属性为orderid, item, customer_name, order_date, price
的表。
我想要Oracle查询
请帮忙 感谢
答案 0 :(得分:0)
这将为您提供最高项目和customer_name ='Joe Schmoe'的订单总数。
SELECT *
FROM
(
SELECT item, count(item) AS item_cnt
FROM orders
WHERE customer_name = 'Joe Schmoe'
GROUP BY item
ORDER BY item_cnt DESC NULLS LAST, item
)
WHERE ROWNUM = 1;