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 ....
oracle 學習筆記 1
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.