来源表1:

来源表2:

生成一个交叉表:

sql:

select t.course_name,
max(case when t.month=\’200706\’ then \’o\’ else \’*\’ end) “6月”,
max(case when t.month=\’200707\’ then \’o\’ else \’*\’ end) “7月”,
max(case when t.month=\’200708\’ then \’o\’ else \’*\’ end) “8月”
from
(select month,course_name from dim_ia_test20 a,dim_ia_test21 b where a.course_id=b.course_id)t
group by course_name;

版权声明:本文为xiao02fang原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/xiao02fang/p/10512008.html