题解 | 商品id数据清洗统计
商品id数据清洗统计
https://www.nowcoder.com/practice/c985ecbd820b46e6bafa858f6600126d
with p_id as (
SELECT
order_id,
SUBSTRING_INDEX(order_id, '_', -1) AS product_id
FROM order_log
)
select product_id,count(*) as cnt
from p_id
group by product_id
提取字段:使用SUBSTRING_INDEX函数从order_id中提取product_id。order_id的格式为order_id_product_id,我们需要提取最后一部分。