右下角图片
2024-09 思扣SQLintern 入门

上一题输出了前2个字段,本题输出前3个字段trx_mon、last_day、day_of_mon

范围限定在渣男(usr_id=5201314520)在2023、2024年,休闲娱乐类目下的所有消费。

trx_mon last_day days_of_mon trx_amt trx_cnt avg_day_amt avg_day_cnt
2024-01 2024-01-31 31 3100 10 310 0.3225
2024-02 2024-02-29 29 5800 20 290 0.6896
2024-03 2024-03-31 31 3100 10 310 0.3225

考点

新学习1个日期处理函数,day('2024-02-08')--> 8。

入门-闺蜜捉奸记 时间日期 多表连接 left join and max year substr in last_day day

cmb_usr_trx_rcd,支付明细表

usr_id mch_nm trx_time trx_amt
5201314520 肯德基 2023-10-01 12:23:24 49
5211414521 丝芙源网络 2024-03-13 17:23:23 123

cmb_mch_typ,商户分类表

mch_nm mch_typ
肯德基 餐饮
延长壳牌南乐加油站 汽车出行
东海洗浴 休闲娱乐

 成为会员,解锁300道大厂数分SQL真题

ID30 子查询(1)玩的最嗨那天在做甚?要用Where子查询
入门 and max year 时间日期 聚合函数 CTE或SubQuery 入门-闺蜜捉奸记 思扣SQLintern
ID37 时间日期(1)按月统计日花费,一天都不要浪费  
入门 and max year substr in last_day 时间日期 入门-闺蜜捉奸记 思扣SQLintern
ID39 时间日期(3)按月统计日花费,一天都不要浪费  
入门 group by left join and max year count sum substr in / last_day day 时间日期 聚合函数 多表连接 入门-闺蜜捉奸记 思扣SQLintern
ID40 时间日期(4)阶段综合-按月统计日花费,一天都不要浪费  
中等 group by left join between and or and max distinct count sum coalesce round / last_day day null 时间日期 聚合函数 断点缝合 多表连接 CTE或SubQuery 入门-闺蜜捉奸记 思扣SQLintern
ID216 想念她的味道,工资献给98号  
入门 between and and year day 时间日期 入门-闺蜜捉奸记 思扣SQLintern

MySQL 8.0

00:00