mysql学习打卡day21

今日成果:

select date,pm.name as payment_method,sum(amount) as total_payments from payments p
left join payment_methods pm on p.payment_method = pm.payment_method_id
group by date,payment_method
order by date;
-- group by数据分组,order by数据排序 
-- 语句执行过程:from->where->group by->select->order by

select pm.name as payment_method,sum(amount) as total from payments p
left join payment_methods pm on p.payment_method = pm.payment_method_id
group by pm.name with rollup;
-- 汇总整个结果集,mysql专属其他数据库不一样

感谢各位读者查阅,欢迎各位点赞✍评论⭐收藏+关注!

你可能感兴趣的:(mysql,学习,数据库)