1 / 13

Restricting and Sorting Data

Restricting and Sorting Data. Kroenke, Chapter Two. Topics. Limiting rows selected (Where) Sorting selected rows (Order By). Limiting Rows Selected. SELECT [ DISTINCT ] { * | column [ alias ], … } FROM table [ WHERE condition (s) ] ;. Where Clause Can Compare. Values in columns

ertl
Download Presentation

Restricting and Sorting Data

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Restricting and Sorting Data Kroenke, Chapter Two From Introduction to Oracle:SQL and PL/SQL, Oracle

  2. Topics • Limiting rows selected (Where) • Sorting selected rows (Order By) From Introduction to Oracle:SQL and PL/SQL, Oracle

  3. Limiting Rows Selected SELECT [ DISTINCT ] { * | column [alias], … } FROM table [ WHERE condition (s) ]; From Introduction to Oracle:SQL and PL/SQL, Oracle

  4. Where Clause Can Compare • Values in columns • Literal values • Arithmetic expressions, or • Functions From 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 From Introduction to Oracle:SQL and PL/SQL, Oracle

  6. Comparison Operators • = • > • >= • < • <= • <> Syntax -- WHERE expr operator value From Introduction to Oracle:SQL and PL/SQL, Oracle

  7. Examples From 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 From 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 From 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 From Introduction to Oracle:SQL and PL/SQL, Oracle

  11. Operator Precedence Rules • All comparison operators • NOT • AND • OR Override rules with parenthesis. From 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 From 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||; From Introduction to Oracle:SQL and PL/SQL, Oracle

More Related