SQL Functions

Page 1

Austin Lucas Class of 2011 Battlefield High School

Austin Lucas Class of 2011 – Battlefield High School Information Technology Portfolio








NEXT_DAY Next day of the date specified LAST_DAY Last day of the month ROUND Round date TRUNC Truncate date


TO_CHAR (Number,'format number') SELECT TO_CHAR (cost, '$99,999') FROM DUAL Insert '9's where you would like your numeric placeholders to be Insert 0’s if you want the columns to line up




NVL2(expression1, 'do if 1 is not null', 'do if expression 1 is null') If expression1 IS NOT NULL, then expression2 will be called If expression2 IS NULL, then use expression3 NULLIF(expression1, expresion2) If the two expressions are equal, null is the result


Much like switch in other languages Works like an IF-THEN-ELSE statement CASE expr WHEN comparison_expr1 THEN return_expr1 [WHEN comparison_expr2 THEN return_expr2 WHEN comparison_exprn THEN return_exprn ELSE else_expr] END


Compares the expression to each of the search values Takes out the words THEN and WHEN and replaces them with comas

DECODE(columnl|expression, search1, result1 [, search2, result2,...,] [, default])


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.