select *
from (select * from table11,table12 where table11.id = table12.id and ...) table1,
(select * from table21,table22 where table21.id = table22.id and ....)table2,
(...)table3,
(...)table4,
(...)table5
其中用到了聚合函数,group by ,等基础知识。对于一个sql菜鸟都谈不上的鸟来说,这任务是多艰巨啊啊啊!!!
分析分析:
NVL (SUM (DECODE (tpcl.init_level, 13101001, 1, 0)),0) AS TOTAL_SUM_H,
对这个字段tpcl.init_level进行sum求和计算
decode函数,类似于if else 逻辑,如果tpcl.init_level = 13101001 则 该字段为1,否则为0,
nvl 如果字段为null,则返回0,
ROUND(TOTAL_AVG1/DECODE (TOTAL1, 0, 1, TOTAL1),3)*100 AVERAGE1,
round(number, num_digits)函数 number为四舍五入的数字,num_digits精确值, 函数 返回按指定位数进行四舍五入的数值
这条查询语句 分别从五个子表中查询出数据,其中每个子表都是独立的
with table1 as (select tb1.name,tb2.age from tb1,tb2,tb3 where ... and ...group by tb1.name,tb2,age) ,
table2 as() ,
table3 as()
select * from table1,table2,table3 where .... and ....