Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle WIDTH_BUCKET Function      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

Term: WIDTH_BUCKET

Definition:
The Oracle WIDTH_BUCKET function is used to construct equiwidth histograms, in which the histogram range is divided into intervals that have identical size. For a given expression, the WIDTH_BUCKET function returns the bucket number into which the value of this expression would fall after being evaluated.

WIDTH_BUCKET also creates (when needed) an underflow bucket numbered '0' and an overflow bucket numbered num_buckets+1. These buckets handle values less than min_value and more than max_value, and are helpful in checking the reasonableness or 'sanity' of endpoints.

Arguments
expr
The expression for which the histogram is being created. This expression must evaluate to a number or a datetime value. When expr evaluates to NA, then the expression returns NA.

min_value
An expression that resolves to the minimum end point of the acceptable range for expr. This expression must evaluate to number or datetime values, and cannot evaluate to NA.

max_value
An expression that resolves to the maximum end point of the acceptable range for expr. This expression must evaluate to number or datetime values, and cannot evaluate to NA.

num_buckets
An expression that resolves to a constant indicating the number of buckets. This expression must evaluate to a positive INTEGER.

Example Syntax:

WIDTH_BUCKET(<value>, <min_value>, <max_value>, <number_of_buckets>);


Example Usage:

SELECT customer_id, cust_last_name, credit_limit,
WIDTH_BUCKET(credit_limit, 100, 4000, 10) CREDIT_GRP
FROM customers
WHERE nls_territory = 'SWITZERLAND'
ORDER BY credit_grp;


Related Links:
 
Home      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 68 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?