banjora {na+au+uk{auxilium}}

 

 

Our deepest apologies as this site is currently under construction... also,  this site is being developed with the new Opera 10 browser with speed dial... check it out!

 

 Opera, the fastest and most secure web rowser




cume_dist {aggregate, analytic function}

Posted: November 21, 2008 at 2:00 pm by Liam A. Purefoy
No Comments
Filed Under: Development, Oracle RDBMS, plsql

first_value {analytical function}The Oracle SQL aggregate and analytic function CUME_DIST calculates the cumulative distribution of a value in a group of values. The range of values returned by CUME_DIST is >0 to <=1. Tie values always evaluate to the same cumulative distribution value.

This function takes as arguments any numeric datatype or any nonnumeric datatype that can be implicitly converted to a numeric datatype. Oracle Database determines the argument with the highest numeric precedence, implicitly converts the remaining arguments to that datatype, makes the calculation, and returns NUMBER.

APPLIES TO: Oracle 9i, Oracle 10g, Oracle 11g

SYNTAX: CUME_DIST(value) OVER (partition_clause order_by_clause)

AGGREGATE EXAMPLE: The following example calculates the cumulative distribution of a hypothetical employee with a salary of $15,500 and commission rate of 5% among the employees in the sample table employees:

SELECT
 CUME_DIST(15500, .05) WITHIN GROUP (ORDER BY emp.salary,
emp.commission_pct) cume_dist
FROM
 employees emp;

cume_dist
0.972222222222222

 

ANALYTIC EXAMPLE: The following example calculates the salary percentile for each employee in the purchasing division. For example, 40% of clerks have salaries less than or equal to Himuro.

SELECT
 emp.job_id,
 emp.last_name,
 emp.salary,
 CUME_DIST() OVER (PARTITION BY emp.job_id ORDER BY emp.salary) AS cume_dist
FROM
 employees emp
WHERE
 upper(emp.job_id) LIKE ‘PU%’;

job_id last_name salary cume_dist
PU_CLERK Colmenares 2500 0.2
PU_CLERK Himuro 2600 0.4
PU_CLERK Tobias 2800 0.6
PU_CLERK Baida 2900 0.8
PU_CLERK Khoo 3100 1
PU_MAN Raphaely 11000 1

 

OVERVIEW: Aggregate functions return a single result row based on groups of rows, rather than on single rows. Aggregate functions can appear in select lists and in ORDER BY and HAVING clauses. They are commonly used with the GROUP BY clause in a SELECT statement, where Oracle Database divides the rows of a queried table or view into groups. In a query containing a GROUP BY clause, the elements of the select list can be aggregate functions, GROUP BY expressions, constants, or expressions involving one of these. Oracle applies the aggregate functions to each group of rows and returns a single result row for each group.

If you omit the GROUP BY clause, then Oracle applies aggregate functions in the select list to all the rows in the queried table or view. You use aggregate functions in the HAVING clause to eliminate groups from the output based on the results of the aggregate functions, rather than on the values of the individual rows of the queried table or view.

Analytic functions compute an aggregate value based on a group of rows. They differ from aggregate functions in that they return multiple rows for each group. The group of rows is called a ‘window’ and is defined by the analytic_clause. For each row, a sliding window of rows is defined. The window determines the range of rows used to perform the calculations for the current row. Window sizes can be based on either a physical number of rows or a logical interval such as time.

Analytic functions are the last set of operations performed in a query except for the final ORDER BY clause. All joins and all WHERE, GROUP BY, and HAVING clauses are completed before the analytic functions are processed. Therefore, analytic functions can appear only in the select list or ORDER BY clause.

  • Navigation
    • Home
    • About Us
    • Contact Us
    • Portfolio
    • Site Map
  • Categories
    • Development
    • Hardware
    • Informational
    • Linux
    • Oracle RDBMS
    • Oracle VM
    • plsql
    • Reviews
    • Software
    • VMware
    • Wordpress
    • Xen
  • Archives
    • August 2009
    • May 2009
    • February 2009
    • November 2008
    • February 2008
    • December 2007
    • November 2007
  • Recent Posts
    • Oracle VM 2.1.5 Server, Final Analysis
    • Installing Oracle VM 2.1.2 Server, Part I
    • The Differences Between Oracle 10g Releases
    • last & first {aggregate function}
    • cume_dist {aggregate, analytic function}
    • dense_rank {aggregate, analytic function}
    • first_value {analytical function}
    • Blocking Executables from an Oracle DB
    • Entrepreneurs benefit with Linkedin…
    • Treo 750 upgrade to Windows Mobile 6!

About Us

Welcome to Banjora [auxilium] entrepreneurs!

Promoting entrepreneurship by supplementing startup companies with viable technology solutions…

Please be patient… this website is currently being revised and energized….

isupport@banjora.com

Recent Postings

  • Oracle VM 2.1.5 Server, Final Analysis
  • Installing Oracle VM 2.1.2 Server, Part I
  • The Differences Between Oracle 10g Releases
  • last & first {aggregate function}
  • cume_dist {aggregate, analytic function}
  • dense_rank {aggregate, analytic function}
  • first_value {analytical function}
  • Blocking Executables from an Oracle DB
  • Entrepreneurs benefit with Linkedin…
  • Treo 750 upgrade to Windows Mobile 6!

Monthly Archives

  • August 2009
  • May 2009
  • February 2009
  • November 2008
  • February 2008
  • December 2007
  • November 2007

 

Category Cloud

    Development (8)
    Hardware (3)
    Informational (4)
    Linux (2)
    Oracle RDBMS (6)
    Oracle VM (2)
    plsql (6)
    Reviews (2)
    Software (4)
    VMware (2)
    Wordpress (1)
    Xen (2)

    WP Cumulus Flash tag cloud by Roy Tanck and Luke Morton requires Flash Player 9 or better.

Site Search

Site Navigation

  • Home
  • About Us
  • Contact Us
  • Portfolio
  • Site Map

banjora {na+au+uk{auxilium}} version 2.9.2 — 28 queries, 0.265 seconds

Entries RSS Comments RSS