9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 1 Restricting and Sorting Data Kroenke, Chapter Two
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 2 Topics Limiting rows selected (Where) Sorting selected rows (Order By)
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 3 Limiting Rows Selected SELECT [ DISTINCT ] { * | column [alias], … } FROMtable [ WHEREcondition (s) ] ;
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 4 Where Clause Can Compare Values in columns Literal values Arithmetic expressions, or Functions
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 5 Character Strings & Dates Enclosed in single quotation marks Character values case sensitive Date values –format sensitive –Default – DD-MON-YY
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 6 Comparison Operators = > >= < <= <> Syntax -- WHERE expr operator value
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 7 Examples
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 8 Other Comparison Operators BETWEEN … AND … Between two values (inclusive) IN(list) Matches any value in list of values LIKE Match a character pattern IS NULL Is a null value
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 9 LIKE Wildcards % any sequence of zero or more characters _ (underscore) any single character ESCAPE Option to match wildcard characters
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 10 Logical Operators AND True if both conditions True OR True if either condition True NOT –True if condition False –False if condition True –Null if condition Null
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 11 Operator Precedence Rules 1.All comparison operators 2.NOT 3.AND 4.OR Override rules with parenthesis.
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 12 ORDER BY Clause Sorts rows –ASC ascending order (default) –DESC descending order Must be last clause in Select statement
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 13 Order By Syntax SELECT expression FROM table [WHERE condition(s)] [ORDER BY {column, expr}|ASC|DESC||;