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

Slides:



Advertisements
Similar presentations
CpSc 3220 The Language of SQL Chapters 7-9. The WHERE Clause Determines which rows of table are to be selected.
Advertisements

2 Restricting and Sorting Data Important Legal Notice:  Materials on this lecture are from a book titled “Oracle Education” by Kochhar, Gravina, and Nathan.
Restricting and sorting data 16 May May May Created By Pantharee Sawasdimongkol.
1Eyad Alshareef Enhanced Guide to Oracle 10g Chapter 3: Using SQL Queries to Insert, Update, Delete, and View Data.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
After completing this lesson, you should be able to do the following: Limit the rows retrieved by a query Sort the rows retrieved by a query.
LECTURE 8.  Consider the table employee(employee_id,last_name,job_id, department_id )  assume that you want to display all the employees in department.
Introduction to Oracle9i: SQL1 Basic SQL SELECT Statements.
Restricting and Sorting Data. Consider the table employee(employee_id,last_name,job_id, department_id ) assume that you want to display all the employees.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
Database Systems and Design
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
WRITING BASIC SQL SELECT STATEMENTS Lecture 7 1. Outlines  SQL SELECT statement  Capabilities of SELECT statements  Basic SELECT statement  Selecting.
Logical Operators Operator AND OR NOT Meaning Returns TRUE if both component conditions are TRUE Returns TRUE if either component condition is TRUE Returns.
Ceng 356-Lab2. Objectives After completing this lesson, you should be able to do the following: Limit the rows that are retrieved by a query Sort the.
1 Copyright © Oracle Corporation, All rights reserved. Writing Basic SQL SELECT Statements.
IFS Intro. to Data Management Chapter 6 Filtering your data.
Chapter 2 Basic SQL SELECT Statements
 The WHERE clause, also called the predicate, provides the power to narrow down the scope of the data retrieved.  Comparison Operators Comparison OperatorDefinition.
15 Structured Query Language (SQL). 2 Objectives After completing this section, you should be able to: Understand Structured Query Language (SQL) and.
Chapter 3 Single-Table Queries
Much from Introduction to Oracle:SQL and PL/SQL, Oracle University 1 Basic SQL Statements Oracle/SQL Plus Commands Kroenke, 11 th ed., Chapter Two.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Restricting and Sorting Data. ◦ Limiting rows with:  The WHERE clause  The comparison conditions using =,
2 Copyright © Oracle Corporation, All rights reserved. Restricting and Sorting Data.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
4 Copyright © 2006, Oracle. All rights reserved. Restricting and Sorting Data.
LECTURE 8.  Consider the table employee(employee_id,last_name,job_id, department_id )  assume that you want to display all the employees in department.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
Introduction to SQL PART Ⅰ 第一讲 Writing Basic SQL SELECT Statements.
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
Restricting and Sorting Data. Objectives After completing this lesson, you should be able to do the following: Limit the rows retrieved by a query Sort.
2 第二讲 Restricting and Sorting Data. Objectives After completing this lesson, you should be able to do the following: Limit the rows retrieved by a query.
Copyright © 2004, Oracle. All rights reserved. Retrieving Data Using the SQL SELECT Statement Satrio Agung Wicaksono, S.Kom., M.Kom.
Copyright © 2004, Oracle. All rights reserved. Lecture 4: 1-Retrieving Data Using the SQL SELECT Statement 2-Restricting and Sorting Data Lecture 4: 1-Retrieving.
1 Querying a Single Table Structured Query Language (SQL) - Part II.
Queries SELECT [DISTINCT] FROM ( { }| ),... [WHERE ] [GROUP BY [HAVING ]] [ORDER BY [ ],...]
Retrieving Data Using the SQL SELECT Statement. Objectives After completing this lesson, you should be able to do the following: – List the capabilities.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
I-1 Copyright س Oracle Corporation, All rights reserved. Data Retrieval.
SQL: Part 2 Original materials supplied by the Oracle Academic Initiative (OAI). Edited for classroom use by Professor Laku Chidambaram. Not for commercial.
Copyright س Oracle Corporation, All rights reserved. I Introduction.
2 Copyright © 2009, Oracle. All rights reserved. Restricting and Sorting Data.
2-1 Limiting Rows Using a Selection “…retrieve all employees in department 10” EMP EMPNO ENAME JOB... DEPTNO 7839KINGPRESIDENT BLAKEMANAGER CLARKMANAGER.
A Guide to SQL, Eighth Edition Chapter Four Single-Table Queries.
1 Chapter 2 Basic SQL SELECT Statements. 2 Chapter Objectives Distinguish between an RDBMS and an ORDBMS Identify keywords, mandatory clauses, and optional.
IST 220 – Intro to DB Lab 2 Specifying Criteria in SELECT Statements.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
Rules of Precedence The rules of precedence determine the order in which expressions are evaluated and calculated. The next table lists the default order.
Simple Queries DBS301 – Week 1. Objectives Basic SELECT statement Computed columns Aliases Concatenation operator Use of DISTINCT to eliminate duplicates.
Writing Basic SQL SELECT Statements Lecture
Limiting Selected Rows. 2-2 Objectives Sort row output using the ORDER BY clause. Sort row output using the ORDER BY clause. Enter search criteria using.
1 ORACLE I 3 – SQL 1 Salim Phone: YM: talim_bansal.
Communicating with a RDBMS Using SQL Database SQL> SELECT loc 2 FROM dept; SQL> SELECT loc 2 FROM dept; SQL statement is entered Statement is sent to database.
IST 220 – Intro to DB Lab 2 Specifying Criteria in SELECT Statements.
Restricting and Sorting Data
Enhanced Guide to Oracle 10g
Writing Basic SQL SELECT Statements
Basic select statement
ATS Application Programming: Java Programming
Restricting and Sorting Data
Restricting and Sorting Data
Writing Basic SQL SELECT Statements
Restricting and Sorting Data
Restricting and Sorting Data
Writing Basic SQL SELECT Statements
Restricting and Sorting Data
Restricting and Sorting Data
MySQL SQL for MySQL (I) Salim Mail :
Lab 2: Retrieving Data from the Database
Presentation transcript:

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||;