标题:有大佬能帮我看看这个怎么写吗
取消只看楼主
fuckamerica
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2022-10-14
 问题点数:0 回复次数:0 
有大佬能帮我看看这个怎么写吗
Please write a query to get the top 3 item_id (has most distinct order_ids) for each category and their order count together with its rank for each category.
Table: item_sales_information
 
+-------------+----------+
| Column Name | Type |
+-------------+----------+
| item_id | int |
| order_id | int |
| category | varchar |
| sold_date | timestamp|
+-------------+----------+
 
Your query should return the following output for the above table:
 
+----------+---------------+------------+------+
| item_id | order_count | category | rank |
+----------+---------------+------------+------+
| t3902 | 2599 | Clothes | 1 |
| t7892 | 2320 | Clothes | 2 |
| t1829 | 1878 | Clothes | 3 |
| k1290 | 1299 | Shoes | 1 |
| k4729 | 872 | Shoes | 2 |
| k0173 | 729 | Shoes | 3 |
... |
+----------+---------------+------------+------+
搜索更多相关主题的帖子: Table for the rank query 
2022-10-14 14:55



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-510313-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.051841 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved