Oracle group Statistics, extract each group of top ten

Source: Internet
Author: User

/**
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.