You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
with temp as (
select distinct customer_id from store
group by customer_id havingmax(amount) >500
) selectcount(*) as rich_count from temp
解析
方法二的另一种写法,使用 with 创建临时表
SQL:方法四
selectcount(*) as rich_count from (
select
distinct customer_id,
max(amount) over(partition by customer_id) as`max`from store
) as temp where`max`>500;
解析
使用窗口函数筛选出每个用户最大的金额,作为临时表 temp
查询 temp 筛选出大于 500 的进行计数
The text was updated successfully, but these errors were encountered:
题目
查询至少有一个订单金额大于 500 的客户数量。
SQL:方法一
解析
500
的数据customer_id
去重计数SQL:方法二
解析
customer_id
分组,并筛选出amount
大于500
的客户,作为临时表temp
temp
计数SQL:方法三
解析
方法二的另一种写法,使用
with
创建临时表SQL:方法四
解析
temp
temp
筛选出大于500
的进行计数The text was updated successfully, but these errors were encountered: