IFS180.81 Intro. to Data Management Chapter 6 Filtering your data.

Slides:



Advertisements
Similar presentations
WHERE Clause Chapter 2. Objectives Limit rows by using a WHERE clause Use the LIKE operator Effect of NULL values Use compound conditions Use the BETWEEN.
Advertisements

CpSc 3220 The Language of SQL Chapters 7-9. The WHERE Clause Determines which rows of table are to be selected.
CSC271 Database Systems Lecture # 11.
Restricting and sorting data 16 May May May Created By Pantharee Sawasdimongkol.
Copyright  Oracle Corporation, All rights reserved. 2 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.
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.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
Structured Query Language Part I Chapter Three CIS 218.
JavaScript, Fourth Edition
JavaScript, Third Edition
Introduction to Structured Query Language (SQL)
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.
Computer Science 1000 Spreadsheets II Permission to redistribute these slides is strictly prohibited without permission.
 The WHERE clause, also called the predicate, provides the power to narrow down the scope of the data retrieved.  Comparison Operators Comparison OperatorDefinition.
Chapter 3 Single-Table Queries
Microsoft Access 2010 Chapter 7 Using SQL. Change the font or font size for SQL queries Create SQL queries Include fields in SQL queries Include simple.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 7 INTRODUCTION TO STRUCTURED QUERY LANGUAGE (SQL) Instructor Ms. Arwa.
Java Primitives The Smallest Building Blocks of the Language (corresponds with Chapter 2)
IFS180 Intro. to Data Management Chapter 9 – Outer Joins.
Chapter 3: Data Types and Operators JavaScript - Introductory.
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.
SQL: Data Manipulation Presented by Mary Choi For CS157B Dr. Sin Min Lee.
1 Single Table Queries. 2 Objectives  SELECT, WHERE  AND / OR / NOT conditions  Computed columns  LIKE, IN, BETWEEN operators  ORDER BY, GROUP BY,
SQL (DDL & DML Commands)
Copyright Curt Hill SQL Queries Yet Another Set of Query Features.
SQL Data Manipulation II Chapter 5 CIS 458 Sungchul Hong.
Instructor: Craig Duckett Lecture 08: Thursday, October 22 nd, 2015 Patterns, Order of Evaluation, Concatenation, Substrings, Trim, Position 1 BIT275:
5. Simple SQL using Oracle1 Simple SQL using Oracle 5. Working with Tables: Data management and Retrieval 6. Working with Tables: Functions and Grouping.
1 ITN270 Advanced Internet Databases Lecture 02. Operators and Function Reference Topics: – Explain & Demonstrate How You Can Use MySQL Operators – Overview.
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.
IFS Intro to Data Management Chapter 5 Getting More Than Simple Columns.
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.
IST 210 SQL Todd Bacastow IST 210: Organization of Data.
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.
2 Copyright © 2004, Oracle. All rights reserved. Restricting and Sorting Data.
Concepts of Database Management Seventh Edition Chapter 3 The Relational Model 2: SQL.
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.
Chapter 14 JavaScript: Part II The Web Warrior Guide to Web Design Technologies.
Restrictions Objectives of the Lecture : To consider the algebraic Restrict operator; To consider the Restrict operator and its comparators in SQL.
IST 210 More SQL Todd Bacastow IST 210: Organization of Data.
Texas State Technical College DISCOVER! Common Predicates Would you like paper or plastic?
IST 220 – Intro to DB Lab 2 Specifying Criteria in SELECT Statements.
Copyright  Oracle Corporation, All rights reserved. 2 Restricting and Sorting Data.
9/29/2005From Introduction to Oracle:SQL and PL/SQL, Oracle 1 Restricting and Sorting Data Kroenke, Chapter Two.
LM 5 Introduction to SQL MISM 4135 Instructor: Dr. Lei Li.
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.
Lecture 11 SQL. Agenda SQL Select statement WHERE clause BindingSource filtering.
1 Section 3 - Select Statement u The Select statement allows you to... –Display Data –Specify Selection Criteria –Sort Data –Group Data for reporting –Use.
Retrieving Information Pertemuan 3 Matakuliah: T0413/Current Popular IT II Tahun: 2007.
Concepts of Database Management, Fifth Edition Chapter 3: The Relational Model 2: SQL.
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
Writing Basic SQL SELECT Statements
Sequence, Selection, Iteration The IF Statement
Topics The if Statement The if-else Statement Comparing Strings
Restricting and Sorting Data
Structured Query Language
Restricting and Sorting Data
Restricting and Sorting Data
Decision Making Using the IF and EVALUATE Statements
Presentation transcript:

IFS Intro. to Data Management Chapter 6 Filtering your data

Filtering Date WHERE clause is used to filter each row in data set with the purpose of creating the given result set (applied to each row in table) WHERE clause follows the FROM clause in a SQL SELECT statement (figure 6-1) Personally, I like the WHERE to precede the ORDER BY clause (it makes logical sense to me)

Filtering Date Consider the WHERE clause a search condition WHERE clause may contain one or more Predicates (i.e. relational tests) of value expressions (combined with ‘and’ and ‘or’) Result of the search are: True False Null

Filtering Data Boolean Operator – AND First search condition Second search condition ANDTrueFalse TrueEvaluate to True. Row selected Evaluate to False. Row Rejected. FalseEvaluate to False. Row Rejected.

Filtering Data Boolean Operator – OR First search condition Second search condition ORTrueFalse TrueEvaluate to True. Row selected False Evaluate to True. Row selected Evaluate to False. Row Rejected.

Filtering Data The AND and OR tables imply only two value expressions. WARNING. I’ve never ran into a limit on the number of Predicates that can be tested. Evaluation of Predicates is controlled by ( ), starting with the inner most set of ( ). The most I’ve ever worked with it 26 predicates.

Filtering data Five basic predicates specified in SQL standard: Comparison Predicate (=, <>, >, =, <=) Between Predicate – specifies a range of values IN Predicate - specifies membership within a given list Like Predicate – pattern match and wildcards Null Predicate – expression evaluates to Null

Filtering Data – Comparison Equal and Not Equal are easy, right? What about unequal length columns? Pad Collating Sequence (for all Predicates): Operating System dependent ASC II = 95 printable characters. Numbers, Upper Case, Lower Case ASC II case insensitive. Numbers, Upper Case and Lower Case equal value (IBM) EBCDIC. Lower, Upper, Numbers

Filtering Data – Comparison Less Than or Greater Than Character Strings: Less Than Precedes (before), Greater Than Follows (After) Numeric. Less Than indicates less than, Greater indicates more than Date. Less Than indicates earlier (before), Greater indicates Later (after)

Filtering Data – Between Filter Range Filter Implemented with the SQL Between…And Predicate Important. Starting and Ending Value are part of the range selection In essence, the range filter is interpreted as value 1 >= value 2 and value 1 <= value 3

Filtering Data – IN Filter Set Membership – used to test value expressions for explicitly defined values IN Predicate (some programming languages use the CASE statement) Simply stated, the IN predicate is an OR statement, indicating one value expression must equal to be included in the result set.

Filtering Data – Pattern Matching Pattern Matching Search for patterns of string values or numeric values Search for entire values or partial values  extremely helpful if you can’t spell (like me) Two special characters for searching are ‘%’ and ‘_’ (underscore). Wildcard search characters % sign indicates 0 or more characters ‘_’ sign indicates one and only one character

Filtering Data – Pattern Matching Where value expression LIKE pattern MS Access uses ‘*’ in place of ‘%’ and ‘?’ in place of the ‘_’ Table 6.1 (pg 162) depicts many good examples of wildcard searching Escape sequence ‘\’ used when the value expression includes wildcard characters in the actual data Don’t forget NOT (as not IN, not BETWEEN, not LIKE, not NULL)

Filtering Data – Pattern Matching Order of Precedence of Where clause evaluation: Positive, Negative sign Multiplication, Division Addition, Subtraction =, <>,,, Between, In, Like, IS Null Not And Or Control with parentheses ((((( ))))) Must Equal