select * from (
select t.cl_date from ysu_fams_calculate t where t.cl_countrys='德国'
) b left outer join (
select substr(to_char(a.t_startdate,'yyyy-mm-dd'),0,7) as yf,
sum(case when '、'||a.t_visitcountrys||'、' like '%、德国、%' then 1 else 0 end) as d1,
sum(case when '、'||a.t_visitcountrys||'、' like '%、德国、%' then a.t_members else 0 end) as d2,
sum(case when '、'||a.t_visitcountrys||'、' like '%、英国、%' then 1 else 0 end) as c1,
sum(case when '、'||a.t_visitcountrys||'、' like '%、英国、%' then a.t_members else 0 end) as c2
from ysu_fams_tasks a group by substr(to_char(a.t_startdate,'yyyy-mm-dd'),0,7)
) c on b.cl_date=c.yf order by b.cl_date
比较复杂的SQL交叉表语句
最新推荐文章于 2021-09-03 11:23:14 发布