Database Reference
In-Depth Information
ROUND(1.4) = 1
ROUND(1.5) = 2
ROUND(1.42356,2) = 1.42
ROUND(1.42356,3) = 1.424
ROUND(18755.24,-2) = 18800
SIGN(n) . Returns -1 if negative, 0 if 0, and 1 if positive.
SIGN(-5032) = -1
SIGN(0) = 0
SIGN(5000) = 1
SQRT(n) . Calculates the square root of a number.
SQRT(4) = 2 (2 * 2 = 4)
TRUNC(n [, places]) . TRUNC is a truncate function. A truncate
function always rounds down by removing trailing numerals from a
number, effectively rounding down regardless of the .5 cutoff value.
TRUNC can also truncate both sides of the decimal point.
TRUNC(147.65,1) = 147.6
TRUNC(147.65,-2) = 100
Other Mathematical Functions . The following functions perform
obscure mathematical or trigonometric calculations. These types of
functions are rarely used other than in financial or numerically
related applications. Some of these functions are listed here. There are
many other Oracle built-in functions to do all sorts of weird and
wonderful things (see Oracle documentation).
SIN(n), COS(n), and TAN(n). Sine, cosine, and tangent.
ASIN(n), ACOS(n), and ACOS(n). Arcsine, arccosine, and arctan-
gent (the inverse of sine, cosine, and tangent).
SINH(n), COSH(n), and TANH(n). Hyperbolic sine, cosine, and
tangent.
EXP(n), LN(n), and LOG(n). e raised to the nth power, the natural
logarithm, and the logarithm.
Here is a query using some of the number functions mentioned.
The query uses the STUDIOTIME table and applies various func-
tions to the AMOUNT_CHARGED column values. The result is
shown in Figure 9.7.
SELECT ST.ARTIST_ID, ST.AMOUNT_CHARGED "Amount"
, ROUND(ST.AMOUNT_CHARGED,1) "Rounded to one decimal"
Search WWH ::




Custom Search