/**
June 14, 2018 Chaozhou
Oracel Statistics 2017 electricity consumption, by industry classification of the first ten
*/
Select *
from (select T.YHBH user number,
T.YHMC User name,
t.jldbh metering point number,
(select M.dmbmmc
from NPMIS_XT_DMBM m
where m.dmfl = ' Ydlxdm '
and M.DMBM = t.ydlb DM) Power type,
(select M.dmbmmc
from NPMIS_XT_DMBM m
Where m.dmbmbs = (select M.sjdmbmbs
from NPMIS_XT_DMBM m where m.dmfl = ' hyfldm '
and M.DMBM = T.HYFLDM)] Superior Industry Classification,
(select M.dmbmmc
from NPMIS_XT_DMBM m
where M.D MFL = ' hyfldm '
and M.DMBM = T.HYFLDM) Industry classification,
SUM (T.JFDL) total charge,
Row_number () over (partition by T.HYFLDM order B Y sum (T.JFDL) desc) The industry ranks
from Npmis_hs_jldxx T
where t.dfny like ' 2017% '
and T.YDLBDM in (' 100 ', ' 200 ', ' 260 ' , ' 300 ')/** Power Category: Large industrial, non-general industrial, non-industrial, commercial */
and T.JFDL <> 0/** charge power not 0*/
and T.YHZTDM <> ' 2 '/** user status is not for pin home */
GROUP by T.YHBH, T.YHMC, T.JLDBH, T.YDLBDM, T.HYFLDM
have sum (T.JFDL) > 500000
Order by total charge charge)
where bank Industry rankings <;
Oracle Group Statistics, extract each group of top ten