记录在工作中会常用到的部分SQL
程序员文章站
2022-06-30 08:53:37
记录在工作中会常用到的部分sql
select a.id, sum(a.tingdou_amount) 挺豆余额, sum(a.tbi_amount) t币余额, sum(a.tdian_amo...
记录在工作中会常用到的部分sql
select a.id, sum(a.tingdou_amount) 挺豆余额, sum(a.tbi_amount) t币余额, sum(a.tdian_amount) t点余额 from (select userid as id, avail_amount as tingdou_amount, 0 as tbi_amount, 0 as tdian_amount from db_wlt_gameplatform.game_user_account where userid in (123) union all select user_id as id, 0 as tingdou_amount, available_coin/500 as tbi_amount, 0 as tdian_amount from db_wlt_gameplatform.game_customize_user_account where user_id in (123) union all select u.id as id, 0 as tingdou_amount, 0 as tbi_amount, sum( t.points )/500 as tdian_amount from db_wlt_gamepoint.points_user_total t inner join db_wlt_gameplatform.game_user u on t.passport_id = u.passport_id where u.id in (123) and (t.overdue_date > now( ) or overdue_date = '0000-00-00 00:00:00') and t.delete_flag =0 group by u.id) as a group by a.id
下一篇: 一起来做莴苣叶水饺,简单好吃又营养