关于求和后排序的sql问题
我有一个产品表,其中包含一次的所有销售数量..所以该表是:
id |产品部门 ID |产品 ID | amount_sold
我需要列出所有product_department_ids 中最畅销的 2 个产品。我有什么想法可以这样做吗?
如果你能在 pl/sql 中做到这一点那就太好了,但 sql 也可以!
谢谢 !
i have a products table that contains all the sales as in quantity made at a time .. so the table is :
id | product_department_id | product_id | quantity_sold
i need to list for all the product_department_ids the best 2 selling products . Any ideas how i can do so ?
if you can do it in pl/sql it would be great but sql is ok also !
Thanks !
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑仍然不确定到底问了什么,但如果组合产品/部门可以有多个条目,那么它将是:
Edit Still not sure about what exactly was asked, but if the combination prodcut/department can have multple entries then it would be:
如果一种产品只能有一个部门,您只需
order by
即可:If a product can have only one department, you can simply
order by
: