teradata - teradata - SQL GROUP BY所有可能的变量





SELECT Column1, Column2, COUNT(*) 


FROM Table


GROUP BY Column1, Column2;



如果我要使用这个代码,我无法看到column1的每个变量的column2中的所有变量(我希望可以看到)。

时间:


SELECT max(Column1), Column2, COUNT(*) 


FROM test


GROUP BY Column2;



cross join然后,是left join :


select c1.column1, c2.column2, count(t.column1)


from (select distinct column1 from t) c1 cross join


 (select distinct column2 from t) c2 left join


 t


 on t.column1 = c1.column1 and t.column2 = c2.column2


group by c1.column1, c2.column2;



...