比例函数相关语句

2014-11-24 01:08:20 · 作者: · 浏览: 6
比例函数相关语句
[sql] 
SQL>   
SQL> select sum(ct) as ct, sum(ratio_ct) as ratio_ct, object_type  
  2    from (select count(*) as ct,  
  3                 round(ratio_to_report(count(*)) over() * 100, 2) as ratio_ct,  
  4                 object_type  
  5            from test  
  6           group by object_type)  
  7   group by rollup(object_type)  
  8  /  
   
        CT   RATIO_CT OBJECT_TYPE  
---------- ---------- -------------------  
      9484      11.88 INDEX  
     22920      28.72 JAVA CLASS  
      1231       1.54 LOB  
      1345       1.69 PACKAGE  
      1284       1.61 PACKAGE BODY  
      1563       1.96 SEQUENCE  
     28561      35.78 SYNONYM  
      5371       6.73 TABLE  
      2886       3.62 TYPE  
      5171       6.48 VIEW  
     79816     100.01   
   
11 rows selected