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-27 16:42:16 发布
本文介绍了一个复杂的SQL查询案例,该查询旨在从多个表中提取特定国家(如德国和英国)的相关统计数据,并按日期进行排序。涉及子查询、连接操作及条件筛选等高级SQL技巧。
3856

被折叠的 条评论
为什么被折叠?



