Posts Tagged ‘analytic’

Cool SQL Analytic Function: RATIO_TO_REPORT

RATIO_TO_REPORT is a very handy and useful function. Before going through what it does, let’s first look at this example:

SELECT last_name, salary, ROUND (salary / SUM (salary) OVER () * 100, […]

Cool SQL Analytic Function: NTILE

The NTILE function divides an ordered partition into buckets and assigns a bucket number to each row in the partition.

The buckets are calculated so that each bucket has exactly the same number of rows assigned to it.

If the number of rows in the partition does not divide evenly into the number of buckets, then […]

Keep first, Keep last

A famous person once said: Oracle’s analytic SQL functions rock, Oracle’s analytic SQL functions roll. I totally agree. However, I would like to add to this that they rock and roll on a much faster beat if you know more about them. To explain what I mean, let’s take an example: