SlideShare a Scribd company logo
1 of 16
Database Systems Lab
IT[243]
Lab #:04
Logical Operators
Operator Meaning
AND Returns TRUE if both component
conditions are TRUE
OR Returns TRUE if either component
conditions are TRUE
NOT Returns TRUE if following condition is
FALSE
Using the AND operators
An employee who has a job title of CLERK and earn
more than $1100 will be selected.
Using the OR operators
An employee who has a job title of CLERK or earn more
than $1100 will be selected.
Using the NOT operators
Name and Job title of all the employees whose Job title is
not CLERK , MANAGER or ANALYST
Rules of Precedence
Order Evaluated Operator
1 All comparison
Operators
2 NOT
3 AND
4 OR
Override rules of precedence by using parentheses
Rules of Precedence
2
1
SELECT statement
reads as follows:
Select the row that
if an employee is a
PRESIDENT and
earn more than
$1500.
Or if the employee
is a SALESMAN.
Use of Parenthesis:
To force Priority
2
1 SELECT statement
reads as follows:
Select the row that
if an employee is a
PRESIDENT or
SALESMAN and if
the employee earn
more than $1500.
ORDER BY Clause
• Sort rows with the ORDER BY clause
–ASC: ascending order , default
–DESC: descending order
• The ORDER BY clause comes last in the
SELECT statement.
– SELECT expr
FROM table
[WHERE condition(s)]
[ORDER BY {column exp} [ASC|DESC]];
ORDER BY Clause
Default
Order
Sorting in Descending Order
Sorting in
Descending
Order
Sorting by Column Alias
Column
Alias
Sorting by
Column Alias
Sorting by multiple Columns
Sorting by
multiple
Columns
Assignments
1. Display the Name and Salary for all employees
whose salary is not in the range of $1500 and $
2850.
2. Select the Name. job and start date of employees
hired between February 20,1981 and May
1,1981.Order the query I ascending order by start
date.
3. Display the employee Name and department
number of all employees in departments 10 and
30 in alphabetic order by name.
4. Display the name and job title of all employees
who do not have a manger.
5. Display the name , salary and commission for all
employees who earn commission. Sort data in
descending order of Salary and commission.
6. Display the name of all employees where the
third letter of their name is an A.
7. Display the name, salary and commission for all
employees whose job is clerk or analyst and their
salary is not equal to $ 1000.$3000 or $5000.
Database systems administration traning  04

More Related Content

Similar to Database systems administration traning 04

Similar to Database systems administration traning 04 (20)

Sql order by clause
Sql order by clauseSql order by clause
Sql order by clause
 
Module 3.1.pptx
Module 3.1.pptxModule 3.1.pptx
Module 3.1.pptx
 
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMS
 
Les02
Les02Les02
Les02
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
 
Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 
Les02
Les02Les02
Les02
 
Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)Database Systems - SQL - DDL Statements (Chapter 3/3)
Database Systems - SQL - DDL Statements (Chapter 3/3)
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
Subquery.pptx
Subquery.pptxSubquery.pptx
Subquery.pptx
 
SQL
SQLSQL
SQL
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle Database
 
Sql query [select, sub] 4
Sql query [select, sub] 4Sql query [select, sub] 4
Sql query [select, sub] 4
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Sql2
Sql2Sql2
Sql2
 
Les06
Les06Les06
Les06
 
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)
 
SQL.pptx
SQL.pptxSQL.pptx
SQL.pptx
 
Module03
Module03Module03
Module03
 

More from Shahid Riaz

Shimla deputation (1906)
Shimla deputation (1906)Shimla deputation (1906)
Shimla deputation (1906)Shahid Riaz
 
#Syed ahmad shaheed barailvi
#Syed ahmad shaheed barailvi#Syed ahmad shaheed barailvi
#Syed ahmad shaheed barailviShahid Riaz
 
How to program in c++ with 100 examples
How to program in c++ with 100 examples  How to program in c++ with 100 examples
How to program in c++ with 100 examples Shahid Riaz
 
Virtual private networks in theory and practice
Virtual private networks in theory and practiceVirtual private networks in theory and practice
Virtual private networks in theory and practiceShahid Riaz
 
Database systems administration week 1
Database systems administration week 1Database systems administration week 1
Database systems administration week 1Shahid Riaz
 
Database systems administration traning 02
Database systems administration traning 02Database systems administration traning 02
Database systems administration traning 02Shahid Riaz
 
Database systems administration traning 02
Database systems administration traning 02Database systems administration traning 02
Database systems administration traning 02Shahid Riaz
 
Database systems administration traning 01
Database systems administration traning 01Database systems administration traning 01
Database systems administration traning 01Shahid Riaz
 
Database systems administration traning 0
Database systems administration traning 0Database systems administration traning 0
Database systems administration traning 0Shahid Riaz
 
Managing people and organizing team
Managing people and organizing teamManaging people and organizing team
Managing people and organizing teamShahid Riaz
 
Lec 1 intro to internet
Lec 1 intro to internetLec 1 intro to internet
Lec 1 intro to internetShahid Riaz
 
Course guidlines course book it 3548
Course guidlines course book it 3548Course guidlines course book it 3548
Course guidlines course book it 3548Shahid Riaz
 
Lecture12 software design class diagram
Lecture12 software design class diagramLecture12 software design class diagram
Lecture12 software design class diagramShahid Riaz
 
Lecture11 use case sequence diagram
Lecture11 use case sequence diagramLecture11 use case sequence diagram
Lecture11 use case sequence diagramShahid Riaz
 
Lecture10 use case model operation contracts
Lecture10 use case model operation contractsLecture10 use case model operation contracts
Lecture10 use case model operation contractsShahid Riaz
 
Lecture9 domain model visualizing
Lecture9 domain model visualizingLecture9 domain model visualizing
Lecture9 domain model visualizingShahid Riaz
 
Lecture8 system sequence
Lecture8 system sequenceLecture8 system sequence
Lecture8 system sequenceShahid Riaz
 
Lecture7 use case modeling
Lecture7 use case modelingLecture7 use case modeling
Lecture7 use case modelingShahid Riaz
 
Lecture6 activity diagrams
Lecture6 activity diagramsLecture6 activity diagrams
Lecture6 activity diagramsShahid Riaz
 
Lecture 5 defining the system
Lecture 5 defining the systemLecture 5 defining the system
Lecture 5 defining the systemShahid Riaz
 

More from Shahid Riaz (20)

Shimla deputation (1906)
Shimla deputation (1906)Shimla deputation (1906)
Shimla deputation (1906)
 
#Syed ahmad shaheed barailvi
#Syed ahmad shaheed barailvi#Syed ahmad shaheed barailvi
#Syed ahmad shaheed barailvi
 
How to program in c++ with 100 examples
How to program in c++ with 100 examples  How to program in c++ with 100 examples
How to program in c++ with 100 examples
 
Virtual private networks in theory and practice
Virtual private networks in theory and practiceVirtual private networks in theory and practice
Virtual private networks in theory and practice
 
Database systems administration week 1
Database systems administration week 1Database systems administration week 1
Database systems administration week 1
 
Database systems administration traning 02
Database systems administration traning 02Database systems administration traning 02
Database systems administration traning 02
 
Database systems administration traning 02
Database systems administration traning 02Database systems administration traning 02
Database systems administration traning 02
 
Database systems administration traning 01
Database systems administration traning 01Database systems administration traning 01
Database systems administration traning 01
 
Database systems administration traning 0
Database systems administration traning 0Database systems administration traning 0
Database systems administration traning 0
 
Managing people and organizing team
Managing people and organizing teamManaging people and organizing team
Managing people and organizing team
 
Lec 1 intro to internet
Lec 1 intro to internetLec 1 intro to internet
Lec 1 intro to internet
 
Course guidlines course book it 3548
Course guidlines course book it 3548Course guidlines course book it 3548
Course guidlines course book it 3548
 
Lecture12 software design class diagram
Lecture12 software design class diagramLecture12 software design class diagram
Lecture12 software design class diagram
 
Lecture11 use case sequence diagram
Lecture11 use case sequence diagramLecture11 use case sequence diagram
Lecture11 use case sequence diagram
 
Lecture10 use case model operation contracts
Lecture10 use case model operation contractsLecture10 use case model operation contracts
Lecture10 use case model operation contracts
 
Lecture9 domain model visualizing
Lecture9 domain model visualizingLecture9 domain model visualizing
Lecture9 domain model visualizing
 
Lecture8 system sequence
Lecture8 system sequenceLecture8 system sequence
Lecture8 system sequence
 
Lecture7 use case modeling
Lecture7 use case modelingLecture7 use case modeling
Lecture7 use case modeling
 
Lecture6 activity diagrams
Lecture6 activity diagramsLecture6 activity diagrams
Lecture6 activity diagrams
 
Lecture 5 defining the system
Lecture 5 defining the systemLecture 5 defining the system
Lecture 5 defining the system
 

Recently uploaded

WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationJuha-Pekka Tolvanen
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 

Recently uploaded (20)

WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
WSO2Con2024 - Facilitating Broadband Switching Services for UK Telecoms Provi...
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid Environments
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in UgandaWSO2CON 2024 - Building a Digital Government in Uganda
WSO2CON 2024 - Building a Digital Government in Uganda
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of TransformationWSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
WSO2CON 2024 - Designing Event-Driven Enterprises: Stories of Transformation
 
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
 
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
WSO2Con2024 - GitOps in Action: Navigating Application Deployment in the Plat...
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 

Database systems administration traning 04

  • 2. Logical Operators Operator Meaning AND Returns TRUE if both component conditions are TRUE OR Returns TRUE if either component conditions are TRUE NOT Returns TRUE if following condition is FALSE
  • 3. Using the AND operators An employee who has a job title of CLERK and earn more than $1100 will be selected.
  • 4. Using the OR operators An employee who has a job title of CLERK or earn more than $1100 will be selected.
  • 5. Using the NOT operators Name and Job title of all the employees whose Job title is not CLERK , MANAGER or ANALYST
  • 6. Rules of Precedence Order Evaluated Operator 1 All comparison Operators 2 NOT 3 AND 4 OR Override rules of precedence by using parentheses
  • 7. Rules of Precedence 2 1 SELECT statement reads as follows: Select the row that if an employee is a PRESIDENT and earn more than $1500. Or if the employee is a SALESMAN.
  • 8. Use of Parenthesis: To force Priority 2 1 SELECT statement reads as follows: Select the row that if an employee is a PRESIDENT or SALESMAN and if the employee earn more than $1500.
  • 9. ORDER BY Clause • Sort rows with the ORDER BY clause –ASC: ascending order , default –DESC: descending order • The ORDER BY clause comes last in the SELECT statement. – SELECT expr FROM table [WHERE condition(s)] [ORDER BY {column exp} [ASC|DESC]];
  • 11. Sorting in Descending Order Sorting in Descending Order
  • 12. Sorting by Column Alias Column Alias Sorting by Column Alias
  • 13. Sorting by multiple Columns Sorting by multiple Columns
  • 14. Assignments 1. Display the Name and Salary for all employees whose salary is not in the range of $1500 and $ 2850. 2. Select the Name. job and start date of employees hired between February 20,1981 and May 1,1981.Order the query I ascending order by start date. 3. Display the employee Name and department number of all employees in departments 10 and 30 in alphabetic order by name.
  • 15. 4. Display the name and job title of all employees who do not have a manger. 5. Display the name , salary and commission for all employees who earn commission. Sort data in descending order of Salary and commission. 6. Display the name of all employees where the third letter of their name is an A. 7. Display the name, salary and commission for all employees whose job is clerk or analyst and their salary is not equal to $ 1000.$3000 or $5000.