Database Reference
In-Depth Information
MIN and MAX are short for minimum and maximum. Given a list of values,
they return the smallest value or the biggest value, respectively.
SELECT MAX(Cost_price) AS max_price
FROM product_info;
OR
SELECT MIN(Cost_price) AS min_price
FROM product_info;
AVG
Another aggregate function is the AVG function. This function averages the
values passed in to it. AVG() can be used to return the average value of all columns or of
specific columns or rows. So, using the product_info again, let's find the average cost of
the Cost_price in the table.
SELECT AVG(Cost_price) AS “Average Cost”
FROM product_info;
Numeric Functions
ABS
ABS is a function used to return the absolute value of the passed-in column value or ex-
pression. You'll see that positive values come out positive, zero values come out zero, and
negative values come out positive .
SELECT ABS(-35) FROM dual ;
OUTPUT: 35
POWER
It is used to returens 'm' raised to 'nth' power. 'n' must be an integer. SELECT
POWER(4,2) FROM dual ;
OUTPUT: 16
CEILING (or CEIL) and FLOOR
The CEILING and FLOOR functions can be used to find the nearest integer above or below
the supplied value. This works like rounding except you specify which direction the value
will round.
SELECT CEILING(35.31) AS RoundUp, FLOOR(35.31) As RoundDown FROM dual;
OUTPUT: RoundUp Round Down
36 3 5
ROUND
Search WWH ::




Custom Search