Oracle中over()

來源:互聯網
上載者:User

標籤:

select to_date(:fr_date,‘yyyy-mm-dd‘) f_date,to_date(:to_date,‘yyyy-mm-dd‘) t_date,nnd,count(distinct memb_id) memb_count,count(bill_id) bill_count,sum(bill_money) pay_count,to_char(round(sum(bill_money)*100/SUM(sum(bill_money)) OVER( ),2),‘990.99‘)||‘%‘ percent from (
select case when c.year_old>=1 and c.year_old<=10 then ‘1-10‘
when c.year_old>=11 and c.year_old<=20 then ‘11-20‘
when c.year_old>=21 and c.year_old<=30 then ‘21-30‘
when c.year_old>=31 and c.year_old<=40 then ‘31-40‘
when c.year_old>=41 and c.year_old<=50 then ‘41-50‘
else ‘50歲以上‘end as nnd,d.bill_id,d.memb_id,d.bill_date,d.bill_money,year_old
from
(select memb_id,floor(months_between(sysdate,BIRTH_DATE)/12) as year_old from TB_AX001 a) c,
(select bill_id,memb_id,bill_date,bill_money from tb_ax006 b where b.bill_date between to_date(:fr_date,‘yyyy-mm-dd‘) and to_date(:to_date,‘yyyy-mm-dd‘)+0.99999) d
where c.memb_id(+) = d.memb_id )e
group by nnd
order by nnd

--SUM(sum(bill_money)) OVER( )總金額

Oracle中over()

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.