Download presentation
Presentation is loading. Please wait.
1
SQL 101 3rd Session
2
Functions: - Character functions - Number functions today - Single Row functions
3
Character Functions: LOWER UPPER INITCAP LPAD RPAD LTRIM RTRIM TRIM SUBSTR INSTR LENGTH in WHERE & GROUP BY clauses Nested functions Concatenation REPLACE TRANSLATE SOUNDEX
4
Number Functions: ABS SIGN ROUND TRUNC FLOOR CEIL MOD REMAINDER Floating point numbers Arithmetic operators
5
Single-Row Functions:
NVL COALESCE NVL2 LNNVL NULLIF NANVL DECODE Searched CASE Simple CASE
6
Number functions.... ABS(value) SIGN(value) ROUND(value [, precision]) TRUNC(value [, precision]) SELECT 'The absolute value of -29 is '||ABS(-29) FROM dual; SELECT -14, SIGN(-14), SIGN(14), SIGN(0), ABS(-14) SELECT , ROUND( , 2), TRUNC( , 1) FROM dual; SELECT , ROUND( , -2), TRUNC( , -1)
7
Round to the number 250 Round to the number Round to ZERO Truncate to 200
8
Number functions.... FLOOR(value) CEIL(value) MOD(value, divisor) REMAINDER(value, divisor) Floating Point Numbers SELECT FLOOR(22.53), CEIL(22.49), TRUNC(22.5), ROUND(22.5) FROM dual; SELECT MOD(23,8) FROM dual; SELECT MOD(23,8), REMAINDER(23,8) FROM dual; Ref: Floating-Point Numbers Oracle Database provides two numeric data types exclusively for floating-point numbers: BINARY_FLOAT and BINARY_DOUBLE. These types support all of the basic functionality provided by the NUMBER data type. However, while NUMBER uses decimal precision, BINARY_FLOAT and BINARY_DOUBLE use binary precision, which enables faster arithmetic calculations and usually reduces storage requirements. BINARY_FLOAT and BINARY_DOUBLE are approximate numeric data types. They store approximate representations of decimal values, rather than exact representations. For example, the value 0.1 cannot be exactly represented by either BINARY_DOUBLE or BINARY_FLOAT. They are frequently used for scientific computations. Their behavior is similar to the data types FLOAT and DOUBLE in Java and XMLSchema.
9
+ - * / Number functions.... SELECT DISTINCT(cost), cost + 10,
+ - * / SELECT DISTINCT(cost), cost + 10, cost – 10, cost * 10, cost / 10 FROM course; SELECT DISTINCT cost + (cost * .10)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.