这句SQL查询语句是什么意思,求高手帮帮忙!

2024-12-29 09:18:17
推荐回答(2个)
回答1:

select rvg01,ogb01,ogb12,ogb14t,ima54 from c001.rvg_file g left join c001.ogb_file b on g.rvg05=b.ogb01 left join c001.ima_file a on b.ogb04=a.ima01 where a.ima54='10056'
这是一个查询结果
select rvg01,ohb01,ohb12,ohb14t,ima54 from c001.rvg_file g left join c001.ohb_file h on g.rvg05=h.ohb01 left join c001.ima_file a on h.ohb04=a.ima01 where a.ima54='10056'
这又是一个查询结果
以上两个查询结果通过UNION ALL和在一起组成一个新的结果集,
然後这个结果集再left join c001.rvc_file,从中分类汇总

你是哪里看不明白呢?如果一点都不懂恐怕很难讲清楚

回答2:

先分析子查询:
(select rvg01,ogb01,ogb12,ogb14t,ima54 from c001.rvg_file g left join c001.ogb_file b on g.rvg05=b.ogb01 left join c001.ima_file a on b.ogb04=a.ima01 where a.ima54='10056'
UNION ALL
select rvg01,ohb01,ohb12,ohb14t,ima54 from c001.rvg_file g left join c001.ohb_file h on g.rvg05=h.ohb01 left join c001.ima_file a on h.ohb04=a.ima01 where a.ima54='10056'
) 联合查询出内容表的别名为:s1
s1 left join c001.rvc_file c on s1.rvg01=c.rvc01 where rvc04>= trunc(sysdate - 30) group by s1.ima54,c.rvc01
左联接查询出内容,
最后就是查出:
sum(s1.ogb12) as ogb12,sum(s1.ogb14t) as ogb14t,s1.ima54,c.rvc01
这几个关键字段的函数的东西。