Echars oracle PL/SQL查詢練習
--echars餅圖查詢
Select * from defect_genetic_analysis
Where s.orgNo like decode( &orgNo,’41101’,’41’,&orgNo) || ‘%’
And s.naturetime between to_date(&starttime, ‘yyyy-mm-dd hh24:mi:ss’)
And to_date(&endtime, ‘yyyy-mm-dd hh24:mi:ss’)
And s.equiptype = &equiptype
And s.naturereasons = & naturereasonse
Group by weathertype
--折線圖查詢
with a as
(select to_char(naturetime,’yyyy-mm-dd’) time1,
Sum(case weathertype when ‘01’ then 1 else 0 end) num1,
Sum(case weathertype when ‘02’ then 1 else 0 end) num2,
Sum(case weathertype when ‘03’ then 1 else 0 end) num3,
Sum(case weathertype when ‘03’ then 1 else 0 end) num4,
From table_weather s
Where s.orgNo like decode(&orgNo,’41101’,’41’,&orgNo) || ‘%’,
And s.naturetime between to_char(to_date(&stsrtTime,’yyyy-mm-dd hh24:mi:ss’))
And to_char(to_date(&endtime+1,’yyyy-mm-dd hh24:mi:ss’)+1)
And s.equiptype = &equiptype
And s.naturereasons = naturereasonse
)
Select a.time1,sum(a.num1 dafeng,sum(a.num2) diwen,sum(a.num3) gaowen,)
From a
Group by a.time1
Order by a.time1