1
echoe 2020-10-27 19:50:07 +08:00
SELECT IFNULL(SUM(a.fee), 0) fee, b.column1, b.column2
FROM xx a RIGHT JOIN (SELECT 0 AS column1, 0 AS column2) b ON a.column1=b.column1 AND a.column2=b.column2 GROUP BY a.column1, a.column2 UNION ALL SELECT IFNULL(SUM(a.fee), 0) fee, b.column1, b.column2 FROM xx a RIGHT JOIN (SELECT 0 AS column1, 1 AS column2) b ON a.column1=b.column1 AND a.column2=b.column2 GROUP BY a.column1, a.column2 UNION ALL SELECT IFNULL(SUM(a.fee), 0) fee, b.column1, b.column2 FROM xx a RIGHT JOIN (SELECT 1 AS column1, 0 AS column2) b ON a.column1=b.column1 AND a.column2=b.column2 GROUP BY a.column1, a.column2 UNION ALL SELECT IFNULL(SUM(a.fee), 0) fee, b.column1, b.column2 FROM xx a RIGHT JOIN (SELECT 1 AS column1, 1 AS column2) b ON a.column1=b.column1 AND a.column2=b.column2 GROUP BY a.column1, a.column2 |