Recently do data analysis, need to use the cumulative function, found that the powerful Oracle really, with over (order by field)
Example:
The last column in the data table is the cumulative effect
Accumulate sql:
Select T.acc_pedal_pos,count (*) Num,sum (COUNT (*)) over (order by T.acc_pedal_pos) Accu_sum from Gt1117cardata t where t.ac C_pedal_pos>0 GROUP BY T.acc_pedal_pos ORDER by T.acc_pedal_pos
Percentage of the sum further calculated based on the cumulative sum
Sql:
--Calculates the cumulative percentage, first the column and then the nesting percent
Select T1.*,round (t1.accu_sum/t2.allsum*100,2) | | % ' from (select T.acc_pedal_pos,
COUNT (*) NUM,
SUM (COUNT (*)) over (order by T.acc_pedal_pos) accu_sum
From Gt1117cardata t
where T.acc_pedal_pos > 0
GROUP BY T.acc_pedal_pos
ORDER by T.acc_pedal_pos) T1, (select count (Acc_pedal_pos) allsum from Gt1117cardata where acc_pedal_pos>0) t2
Oracle cumulative function, percent accumulated