SlideShare une entreprise Scribd logo
1  sur  28
Muhammad Umair
Oracle Database 11g Developer Track
SELECT Data retrieval
INSERT
UPDATE
DELETE
Data manipulation language
(DML)
CREATE
ALTER
DROP
RENAME
TRUNCATE
Data definition language (DDL)
COMMIT
ROLLBACK
SAVEPOINT
Transaction control
GRANT
REVOKE
Data control language (DCL)
SELECT Retrieves data from the database
INSERT
UPDATE
DELETE
Enters new rows, changes existing rows, and removes unwanted rows
from tables in the database, respectively. Collectively known as
Data manipulation language(DML).
CREATE
ALTER
DROP
RENAME
TRUNCATE
Set up, change, and remove data structures from tables. Collectively
known as data definition language(DDL).
COMMIT
ROLLBACK
SAVEPOINT
Manage the changes made by DML statements. Changes to the data can
be grouped together into logical transactions
GRANT
REVOKE
Give or remove access rights to both the Oracle database and the
structures within it. Collectively known as data control language(DCL).
In its simplest form, a SELECT statement must include the following:
•A SELECT clause , which specifies the columns to be displayed
•A FROM clause, which specifies the table containing the columns listed
in the SELECT clause
SELECT is a list of one or more columns
* selects all columns
DISTINCT suppresses duplicates
column|expression selects the named column or the expression
alias gives selected columns different headings
FROM table specifies the table containing the columns
Syntax
SELECT *|{[DISTINCT] column|expression alias],...}
FROM table;
• SQL statements are not case sensitive.
• SQL statements can be on one or more lines.
• Keywords cannot be abbreviated or split across lines.
• Clauses are usually placed on separate lines.
• Indents are used to enhance readability.
SELECT *
FROM departments;
Selecting All Columns of All Rows
You can display all columns of data in a table by following the SELECT
keyword with an asterisk (*). In the example on the slide, the department
table contains four columns:
DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID, and LOCATION_ID.
The table contains seven rows, one for each department.
You can also display all columns in the table by listing all the columns after
the SELECT keyword. For example, the following SQL statement, like the
example on the slide, displays all columns and all rows of the
DEPARTMENTS table:
SELECT department_id, department_name, manager_id, location_id
FROM departments;
Create expressions with number and date data by using arithmetic
operators.
Operator Description
+ Add
- Subtract
* Multiply
/ Divide
SELECT last_name, salary, salary + 300
FROM employees;
Multiplication and division take priority over addition and subtraction.
•Operators of the same priority are evaluated from left to right.
•Parentheses are used to force prioritized evaluation and to clarify
statements.
* / + -
SELECT last_name, salary, 12*(salary+100)
FROM employees;
A column alias:
•Renames a column heading
•Is useful with calculations
•Immediately follows the column name: there can also be the optional
AS keyword between the column name and alias
•Requires double quotation marks if it contains spaces or special
characters or is case sensitive
SELECT last_name AS name, commission_pct comm
FROM employees;
SELECT last_name "Name", salary*12 AS "Annual Salary"
FROM employees;
A concatenation operator:
• Concatenates columns or character strings to other columns
• Is represented by two vertical bars ||
• Creates a resultant column that is a character expression
SELECT last_name||job_id AS "Employees"
FROM employees;
SELECT last_name ||' is a '||job_id AS "Employee Details"
FROM employees;
SELECT last_name ||‘ : 1 Month salary = '||salary Monthly
FROM employees;
Eliminate duplicate rows by using the DISTINCT keyword in the SELECT clause.
SELECT DISTINCT department_id
FROM employees
SELECT DISTINCT department_id, job_id
FROM employees
Use the iSQL*Plus DESCRIBE command to display the structure of a table.
DESCRIBE employees;
Syntax
SELECT *|{[DISTINCT] column|expression alias],...}
FROM table
[WHERE condition(s)];
The WHERE clause can compare values in columns, literal values, arithmetic
expressions, or functions. It consists of three elements:
•Column name
•Comparison condition
•Column name, constant, or list of values
SELECT employee_id, last_name, job_id, department_id
FROM employees
WHERE department_id = 90;
• Character strings and date values are enclosed in single quotation marks.
•Character values are case sensitive, and date values are format sensitive.
•The default date format is DD-MON-RR.
SELECT last_name, job_id, department_id
FROM employees
WHERE last_name ='Goyal';
Operator Meaning
= Equal to
> Greater than
>= Greater than or equal to
< Less than
<= Less than or equal to
<> Not equal to
BETWEEN
...AND...
Between two values (inclusive)
IN(set) Match any of a list of values
LIKE Match a character pattern
IS NULL Is a null value
SELECT last_name, salary
FROM employees
WHERE salary <= 3000;
SELECT last_name, salary
FROM employees
WHERE salary BETWEEN 2500 AND 3500;
SELECT employee_id, last_name, salary, manager_id
FROM employees
WHERE manager_id IN (100, 101, 201);
SELECT employee_id, manager_id, department_id
FROM employees
WHERE last_name IN ('Hartstein’, 'Vargas');
% Represents any sequence of zero or more characters
_ Represents any single character
SELECT first_name
FROM employees
WHERE first_name LIKE ‘_S%';
SELECT first_name
FROM employees
WHERE first_name LIKE ‘%AR_';
Operator Meaning
AND Returns TRUE if both component
conditions are true
OR Returns TRUE if either component
conditions are true
NOT Returns TRUE if the following
condition is false
SELECT employee_id, last_name, job_id, salary
FROM employees
WHERE salary >=10000
AND job_id LIKE '%MAN%‘;
SELECT employee_id, last_name, job_id, salary
FROM employees
WHERE salary >=10000
OR job_id LIKE '%MAN%‘;
SELECT employee_id, last_name, job_id, salary
FROM employees
WHERE job_id NOT IN ('IT_PROG', 'ST_CLERK', 'SA_REP');
•Sort rows with the ORDER BY clause
– ASC : ascending order (the default order)
– DESC : descending order
•The ORDER BY clause comes last in the SELECT statement.
SELECT last_name, job_id, department_id, hire_date
FROM employees
ORDER BY hire_date;
SELECT last_name, job_id, department_id, hire_date
FROM employees
ORDER BY hire_date DESC;
SELECT employee_id, last_name, salary*12 annsal
FROM employees ORDER BY annsal;
SELECT last_name, department_id, salary
FROM employees
ORDER BY department_id, salary DESC;

Contenu connexe

Tendances

Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
Achmad Solichin
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
Achmad Solichin
 
Statements,joins and operators in sql by thanveer danish melayi(1)
Statements,joins and operators in sql by thanveer danish melayi(1)Statements,joins and operators in sql by thanveer danish melayi(1)
Statements,joins and operators in sql by thanveer danish melayi(1)
Muhammed Thanveer M
 

Tendances (20)

Sql
SqlSql
Sql
 
SQL Data Manipulation
SQL Data ManipulationSQL Data Manipulation
SQL Data Manipulation
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Where conditions and Operators in SQL
Where conditions and Operators in SQLWhere conditions and Operators in SQL
Where conditions and Operators in SQL
 
Advanced SQL Webinar
Advanced SQL WebinarAdvanced SQL Webinar
Advanced SQL Webinar
 
A must Sql notes for beginners
A must Sql notes for beginnersA must Sql notes for beginners
A must Sql notes for beginners
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Training
 
introdution to SQL and SQL functions
introdution to SQL and SQL functionsintrodution to SQL and SQL functions
introdution to SQL and SQL functions
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
Sql DML
Sql DMLSql DML
Sql DML
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Introduction to SQL
Introduction to SQLIntroduction to SQL
Introduction to SQL
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
 
SQL
SQLSQL
SQL
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)Les01 (retrieving data using the sql select statement)
Les01 (retrieving data using the sql select statement)
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Statements,joins and operators in sql by thanveer danish melayi(1)
Statements,joins and operators in sql by thanveer danish melayi(1)Statements,joins and operators in sql by thanveer danish melayi(1)
Statements,joins and operators in sql by thanveer danish melayi(1)
 
Data Manipulation Language
Data Manipulation LanguageData Manipulation Language
Data Manipulation Language
 

Similaire à Basic SQL Statments

SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SaiMiryala1
 
Sql intro
Sql introSql intro
Sql intro
glubox
 

Similaire à Basic SQL Statments (20)

Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 
Data Manipulation Language.pptx
Data Manipulation Language.pptxData Manipulation Language.pptx
Data Manipulation Language.pptx
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
sql language
sql languagesql language
sql language
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptxSQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
SQL-Tutorial.P1241112567Pczwq.powerpoint.pptx
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sql
 
Lab
LabLab
Lab
 
Sql intro
Sql introSql intro
Sql intro
 
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)
 
Teradata imp
Teradata impTeradata imp
Teradata imp
 
Les08 (manipulating data)
Les08 (manipulating data)Les08 (manipulating data)
Les08 (manipulating data)
 
Les08
Les08Les08
Les08
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
Select To Order By
Select  To  Order BySelect  To  Order By
Select To Order By
 
lect 2.pptx
lect 2.pptxlect 2.pptx
lect 2.pptx
 
012. SQL.pdf
012. SQL.pdf012. SQL.pdf
012. SQL.pdf
 

Plus de Umair Shakir

Introduction to basic database concepts
Introduction to basic database conceptsIntroduction to basic database concepts
Introduction to basic database concepts
Umair Shakir
 

Plus de Umair Shakir (17)

Database Joins
Database JoinsDatabase Joins
Database Joins
 
Introduction to Sql
Introduction to SqlIntroduction to Sql
Introduction to Sql
 
Services of dbms
Services of dbmsServices of dbms
Services of dbms
 
Constraints
ConstraintsConstraints
Constraints
 
Task of db administrator
Task of db administratorTask of db administrator
Task of db administrator
 
Schema Objects
Schema ObjectsSchema Objects
Schema Objects
 
Relationships
RelationshipsRelationships
Relationships
 
Relational model
Relational modelRelational model
Relational model
 
Normalization
NormalizationNormalization
Normalization
 
Key and its different types
Key and its different typesKey and its different types
Key and its different types
 
Er model
Er modelEr model
Er model
 
Introduction to basic database concepts
Introduction to basic database conceptsIntroduction to basic database concepts
Introduction to basic database concepts
 
Dbms and rdbms
Dbms and rdbmsDbms and rdbms
Dbms and rdbms
 
Database planning
Database planningDatabase planning
Database planning
 
Conceptual database design
Conceptual database designConceptual database design
Conceptual database design
 
Work Sheet
Work SheetWork Sheet
Work Sheet
 
G to a
G to aG to a
G to a
 

Dernier

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Dernier (20)

Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 

Basic SQL Statments

  • 1. Muhammad Umair Oracle Database 11g Developer Track
  • 2. SELECT Data retrieval INSERT UPDATE DELETE Data manipulation language (DML) CREATE ALTER DROP RENAME TRUNCATE Data definition language (DDL) COMMIT ROLLBACK SAVEPOINT Transaction control GRANT REVOKE Data control language (DCL)
  • 3. SELECT Retrieves data from the database INSERT UPDATE DELETE Enters new rows, changes existing rows, and removes unwanted rows from tables in the database, respectively. Collectively known as Data manipulation language(DML). CREATE ALTER DROP RENAME TRUNCATE Set up, change, and remove data structures from tables. Collectively known as data definition language(DDL). COMMIT ROLLBACK SAVEPOINT Manage the changes made by DML statements. Changes to the data can be grouped together into logical transactions GRANT REVOKE Give or remove access rights to both the Oracle database and the structures within it. Collectively known as data control language(DCL).
  • 4. In its simplest form, a SELECT statement must include the following: •A SELECT clause , which specifies the columns to be displayed •A FROM clause, which specifies the table containing the columns listed in the SELECT clause SELECT is a list of one or more columns * selects all columns DISTINCT suppresses duplicates column|expression selects the named column or the expression alias gives selected columns different headings FROM table specifies the table containing the columns
  • 6. • SQL statements are not case sensitive. • SQL statements can be on one or more lines. • Keywords cannot be abbreviated or split across lines. • Clauses are usually placed on separate lines. • Indents are used to enhance readability.
  • 7. SELECT * FROM departments; Selecting All Columns of All Rows You can display all columns of data in a table by following the SELECT keyword with an asterisk (*). In the example on the slide, the department table contains four columns: DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID, and LOCATION_ID. The table contains seven rows, one for each department.
  • 8. You can also display all columns in the table by listing all the columns after the SELECT keyword. For example, the following SQL statement, like the example on the slide, displays all columns and all rows of the DEPARTMENTS table: SELECT department_id, department_name, manager_id, location_id FROM departments;
  • 9. Create expressions with number and date data by using arithmetic operators. Operator Description + Add - Subtract * Multiply / Divide
  • 10. SELECT last_name, salary, salary + 300 FROM employees;
  • 11. Multiplication and division take priority over addition and subtraction. •Operators of the same priority are evaluated from left to right. •Parentheses are used to force prioritized evaluation and to clarify statements. * / + -
  • 12. SELECT last_name, salary, 12*(salary+100) FROM employees;
  • 13. A column alias: •Renames a column heading •Is useful with calculations •Immediately follows the column name: there can also be the optional AS keyword between the column name and alias •Requires double quotation marks if it contains spaces or special characters or is case sensitive SELECT last_name AS name, commission_pct comm FROM employees; SELECT last_name "Name", salary*12 AS "Annual Salary" FROM employees;
  • 14. A concatenation operator: • Concatenates columns or character strings to other columns • Is represented by two vertical bars || • Creates a resultant column that is a character expression SELECT last_name||job_id AS "Employees" FROM employees; SELECT last_name ||' is a '||job_id AS "Employee Details" FROM employees; SELECT last_name ||‘ : 1 Month salary = '||salary Monthly FROM employees;
  • 15. Eliminate duplicate rows by using the DISTINCT keyword in the SELECT clause. SELECT DISTINCT department_id FROM employees SELECT DISTINCT department_id, job_id FROM employees
  • 16. Use the iSQL*Plus DESCRIBE command to display the structure of a table. DESCRIBE employees;
  • 17. Syntax SELECT *|{[DISTINCT] column|expression alias],...} FROM table [WHERE condition(s)]; The WHERE clause can compare values in columns, literal values, arithmetic expressions, or functions. It consists of three elements: •Column name •Comparison condition •Column name, constant, or list of values
  • 18. SELECT employee_id, last_name, job_id, department_id FROM employees WHERE department_id = 90;
  • 19. • Character strings and date values are enclosed in single quotation marks. •Character values are case sensitive, and date values are format sensitive. •The default date format is DD-MON-RR. SELECT last_name, job_id, department_id FROM employees WHERE last_name ='Goyal';
  • 20. Operator Meaning = Equal to > Greater than >= Greater than or equal to < Less than <= Less than or equal to <> Not equal to BETWEEN ...AND... Between two values (inclusive) IN(set) Match any of a list of values LIKE Match a character pattern IS NULL Is a null value
  • 21. SELECT last_name, salary FROM employees WHERE salary <= 3000; SELECT last_name, salary FROM employees WHERE salary BETWEEN 2500 AND 3500; SELECT employee_id, last_name, salary, manager_id FROM employees WHERE manager_id IN (100, 101, 201);
  • 22. SELECT employee_id, manager_id, department_id FROM employees WHERE last_name IN ('Hartstein’, 'Vargas'); % Represents any sequence of zero or more characters _ Represents any single character SELECT first_name FROM employees WHERE first_name LIKE ‘_S%'; SELECT first_name FROM employees WHERE first_name LIKE ‘%AR_';
  • 23. Operator Meaning AND Returns TRUE if both component conditions are true OR Returns TRUE if either component conditions are true NOT Returns TRUE if the following condition is false
  • 24. SELECT employee_id, last_name, job_id, salary FROM employees WHERE salary >=10000 AND job_id LIKE '%MAN%‘;
  • 25. SELECT employee_id, last_name, job_id, salary FROM employees WHERE salary >=10000 OR job_id LIKE '%MAN%‘;
  • 26. SELECT employee_id, last_name, job_id, salary FROM employees WHERE job_id NOT IN ('IT_PROG', 'ST_CLERK', 'SA_REP');
  • 27. •Sort rows with the ORDER BY clause – ASC : ascending order (the default order) – DESC : descending order •The ORDER BY clause comes last in the SELECT statement. SELECT last_name, job_id, department_id, hire_date FROM employees ORDER BY hire_date; SELECT last_name, job_id, department_id, hire_date FROM employees ORDER BY hire_date DESC;
  • 28. SELECT employee_id, last_name, salary*12 annsal FROM employees ORDER BY annsal; SELECT last_name, department_id, salary FROM employees ORDER BY department_id, salary DESC;