You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

不使用自连接获取各产品类型销量最高的地区

SQL问题:无连接实现各产品类型销量最高地区查询

我正在处理一个SQL问题,需要不使用连接实现:从销售数据表中,找出每个product_type下销量总和最高的geography。我能用自连接实现,但要求必须不使用连接完成。

以下是我尝试的SQL代码:

Select region, max(sold_sum) from
(Select distinct region, geo, sum(quat) over (partition by region,geo) as sold_sum 
from tab1 order by 1) t1
group by region

销售数据

product_typegeographyquantity_sold
1E56
1N34
1W56
1W34
2N76
2N98
2W45
2W21
3N67
3S76
3W98
4E43
4S82
4S43
5E21
5S34

预期输出

product_typegeographytotal_sold
1W90
2N174
3W98
4S125
5S34

内容的提问来源于stack exchange,提问作者Prabhat Bhatt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 06:23:11