1.使用COALESCE时,用到group by with cube,如果之前两个表left join时,有数据为null,就会使得查出的数据主键不唯一 例如: select COALESCE (c.value,'total_count')as coupon_price, COALESCE (c.souform,'total_count')as souform, count(c.id)as coupon_num, count(distinct c.auserid,c.code)as user_n…