SlideShare ist ein Scribd-Unternehmen logo
1 von 13
1 Using ORACLE® Introduction to the ‘ SELECT ‘ clause and writing basic and advanced ‘SELECT ‘ statements using operators and literals
2 The “SELECT” statement In this tutorial we will learn about the ‘SELECT’ clause and how to write basic and advanced ‘SELECT’ statements by using literals and operators. The agenda for the presentation shall consist of: Introduction to “SELECT” clause (writing a basic ‘SELECT’ statement). Using the concatenation operator ,character string literals and Mathematical operators in SELECT statement. NULL values and alias names. Restriction and filtering data using comparison operators, logical operators  pattern matching and sorting data.
3 Introduction to ‘SELECT’ statement ‘SELECT’ is an SQL keyword used to retrieve data from Oracle tables .SQL commands are not case  sensitive and can be broken into multiple lines . The basic syntax for a ‘SELECT’ statement is: 		(Here the ‘SELECT’ and ‘FROM’ are keywords) SELECT The ‘SELECT’ clause identifies the columns to be retrieved  */{  [distinct]  			avoids duplicate copies of rows to be retrieved  column_list / expression  	list of names of columns or expression to be selected [alias name]…		name to be used to represent the column in display }  FROM  table name ;	the ‘FROM’ clause identifies the table which contains the  columns to be retrieved. Example: SELECT  prod_name, prod_ID FROM product_master;
The concatenation operator is used to combine string literals and/or columns and displayed in the output. The concatenation operator is ‘ || ‘. The ‘AS’ keyword is used to specify the alias name that will represent the column in the output. We can specify the alias name using the ‘AS’ operator or just by entering the alias name after the column name separated by a space while writing the ‘SELECT’ statement. (if as ‘ ‘ the string literal contains ‘ character then use q’[ string literal ]’ between || operators)  EXAMPLE : SELECT  DISTINCT prod_ID || ‘ is the product ‘ || prod_name AS prod_description  FROM  product_master ; 4 The concatenation operator ( || ) and AS keyword.
Mathematical Operators   5 We can use mathematical operators to create expression in the ‘SELECT’ statement . The mathematical operators are :	 				EXAMPLE: SELECT  prod_name, prod_ID, prod_cost, 					prod_stock     -   prod_order  AS stock_deficit , 					prod_sales   *    prod_cost AS sales_amt FROM product_master ;
Restricting and filtering data 6 In the previous ‘SELECT’ commands all the rows of the selected columns are displayed. We can restrict the rows that are displayed by using the ‘WHERE’ clause in combination with comparison operators and logical operators. The ‘WHERE’ clause follows the ‘FROM’ clause specifies the conditions a row should satisfy to be displayed in the output. We can use logical and comparison operators to create the expression in ‘WHERE’ clause. The operators are: 	       LOGICAL OPERATORS 	       COMPARISIN OPERATORS
EXAMPLES FOR COMPARISION OPERATORS 7 We shall see a few examples using the logical operators: SELECT  prod_ID,prod_name,prod_cost  FROM  product_master WHERE  prod_cost   >   2000   AND   prod_cost   <  25000; SELECT  prod_ID,prod_name,prod_cost  FROM  product_master WHERE  prod_cost   =    30000 ; SELECT  prod_ID,prod_name,prod_cost  FROM  product_master  WHERE  prod_cost  >=  2000   AND   prod_cost  <=  25000;
EXAMPLES FOR  LOGICAL OPERATORS 8 SELECT  prod_ID,prod_name,prod_cost  FROM  product_master WHERE  prod_cost   >   2000   AND   prod_cost   < 25000; SELECT  prod_ID,prod_name,prod_cost  FROM  product_master WHERE  prod_cost   >   2000   OR     prod_cost  <  25000; SELECT  prod_ID,prod_name,prod_cost  FROM  product_master WHERE NOT (prod_cost =2000);
EXAMPLES FOR BETWEEN……AND……. CONDITION AND NULL CONDITION 9 THE BETWEEN…AND CONDITION: SELECT  prod_ID,prod_name,prod_cost  FROM  product_master WHERE  	prod_cost     BETWEEN     2000     AND    25000; lower limit                         upper limit (We use the BETWEEN …AND… condition to find rows containing values in the specified range ) THE NULL CONDITION: SELECT *  FROM product_master WHERE   prod_sales    IS NULL    ; We use the IS NULL condition to find the rows containing NULL values for a particular column.
EXAMPLES FOR LIKE and IN CONDITION  10 THE LIKE CONDITION: SELECT  prod_ID,prod_name,prod_cost  FROM  product_master WHERE      prod_name     LIKE       '%sofa'  ; (We use the like condition when we wish to perform wildcard character pattern matching searches. In the above ‘LIKE’ condition we search for all products containing ‘sofa’ as the terminal characters and use the ‘%’ symbol which is a wildcard for multiple characters .The ‘_’ acts a a wildcard for a single character.) THE IN CONDITION: SELECT  prod_ID,prod_name,prod_cost  FROM  product_master WHEREprod_IDIN      (‘VF001’  ,  ’VF004’   ,  ’VF006’); 	   (We use the IN condition when we wish to search for values belonging 	    to a particular 	      list that is specified after the IN keyword.)
OPERATOR PRECEDENCE 11 Importance of operators decreases
ORDER BY clause 12 The ‘ ORDER BY’ clause is use to display the rows matching the conditions in a ordered format either in ascending order (by using keyword ‘ASC’) or in the descending order (by using keyword ‘DESC’)  with ascending being the default order. 	The rows are ordered according to the values in one or more specified rows. THE ORDER BY CLAUSE: SELECT *  FROM product_master ORDER BY  prod_cost  ASC; SELECT *  FROM product_master ORDER BY prod_cost  DESC;
THANK YOU 13 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit:   www.dataminingtools.net

Weitere ähnliche Inhalte

Was ist angesagt?

SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
Vikas Gupta
 
Retrieving data using the sql select statement
Retrieving data using the sql select statementRetrieving data using the sql select statement
Retrieving data using the sql select statement
Syed Zaid Irshad
 
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
 

Was ist angesagt? (19)

SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and Operators
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Training
 
Advanced SQL Webinar
Advanced SQL WebinarAdvanced SQL Webinar
Advanced SQL Webinar
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
Retrieving data using the sql select statement
Retrieving data using the sql select statementRetrieving data using the sql select statement
Retrieving data using the sql select statement
 
Sql select
Sql select Sql select
Sql select
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive data
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIES
 
Lab5 sub query
Lab5   sub queryLab5   sub query
Lab5 sub query
 
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)
 
Where conditions and Operators in SQL
Where conditions and Operators in SQLWhere conditions and Operators in SQL
Where conditions and Operators in SQL
 
MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 
Les17
Les17Les17
Les17
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
Les18
Les18Les18
Les18
 
Oracle - Program with PL/SQL - Lession 10
Oracle - Program with PL/SQL - Lession 10Oracle - Program with PL/SQL - Lession 10
Oracle - Program with PL/SQL - Lession 10
 
SQL
SQLSQL
SQL
 

Ähnlich wie Oracle: Basic SQL

e computer notes - Restricting and sorting data
e computer notes -  Restricting and sorting datae computer notes -  Restricting and sorting data
e computer notes - Restricting and sorting data
ecomputernotes
 

Ähnlich wie Oracle: Basic SQL (20)

Chinabankppt
ChinabankpptChinabankppt
Chinabankppt
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
Oracle sql tuning
Oracle sql tuningOracle sql tuning
Oracle sql tuning
 
SQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdfSQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdf
 
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)
 
75864 sql
75864 sql75864 sql
75864 sql
 
Les02
Les02Les02
Les02
 
Module03
Module03Module03
Module03
 
Les02
Les02Les02
Les02
 
Sql functions
Sql functionsSql functions
Sql functions
 
ALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMSALL ABOUT SQL AND RDBMS
ALL ABOUT SQL AND RDBMS
 
e computer notes - Restricting and sorting data
e computer notes -  Restricting and sorting datae computer notes -  Restricting and sorting data
e computer notes - Restricting and sorting data
 
ADV Powepoint 3 Lec.pptx
ADV Powepoint 3 Lec.pptxADV Powepoint 3 Lec.pptx
ADV Powepoint 3 Lec.pptx
 
ADV Powepoint 4 Lec.pptx
ADV Powepoint 4 Lec.pptxADV Powepoint 4 Lec.pptx
ADV Powepoint 4 Lec.pptx
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sql
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
Les06
Les06Les06
Les06
 
Les07
Les07Les07
Les07
 
Les02.ppt
Les02.pptLes02.ppt
Les02.ppt
 

Mehr von oracle content (13)

Oracle: Procedures
Oracle: ProceduresOracle: Procedures
Oracle: Procedures
 
Oracle: PLSQL Introduction
Oracle: PLSQL IntroductionOracle: PLSQL Introduction
Oracle: PLSQL Introduction
 
Oracle : DML
Oracle : DMLOracle : DML
Oracle : DML
 
Oracle: Programs
Oracle: ProgramsOracle: Programs
Oracle: Programs
 
Oracle: Commands
Oracle: CommandsOracle: Commands
Oracle: Commands
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
 
Oracle:Cursors
Oracle:CursorsOracle:Cursors
Oracle:Cursors
 
Oracle: Control Structures
Oracle:  Control StructuresOracle:  Control Structures
Oracle: Control Structures
 
Oracle: Dw Design
Oracle: Dw DesignOracle: Dw Design
Oracle: Dw Design
 
Oracle Warehouse
Oracle WarehouseOracle Warehouse
Oracle Warehouse
 
Oracle: Functions
Oracle: FunctionsOracle: Functions
Oracle: Functions
 
Oracle: New Plsql
Oracle: New PlsqlOracle: New Plsql
Oracle: New Plsql
 
Oracle: Fundamental Of Dw
Oracle: Fundamental Of DwOracle: Fundamental Of Dw
Oracle: Fundamental Of Dw
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Kürzlich hochgeladen (20)

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
AI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by AnitarajAI in Action: Real World Use Cases by Anitaraj
AI in Action: Real World Use Cases by Anitaraj
 

Oracle: Basic SQL

  • 1. 1 Using ORACLE® Introduction to the ‘ SELECT ‘ clause and writing basic and advanced ‘SELECT ‘ statements using operators and literals
  • 2. 2 The “SELECT” statement In this tutorial we will learn about the ‘SELECT’ clause and how to write basic and advanced ‘SELECT’ statements by using literals and operators. The agenda for the presentation shall consist of: Introduction to “SELECT” clause (writing a basic ‘SELECT’ statement). Using the concatenation operator ,character string literals and Mathematical operators in SELECT statement. NULL values and alias names. Restriction and filtering data using comparison operators, logical operators pattern matching and sorting data.
  • 3. 3 Introduction to ‘SELECT’ statement ‘SELECT’ is an SQL keyword used to retrieve data from Oracle tables .SQL commands are not case sensitive and can be broken into multiple lines . The basic syntax for a ‘SELECT’ statement is: (Here the ‘SELECT’ and ‘FROM’ are keywords) SELECT The ‘SELECT’ clause identifies the columns to be retrieved */{ [distinct] avoids duplicate copies of rows to be retrieved column_list / expression list of names of columns or expression to be selected [alias name]… name to be used to represent the column in display } FROM table name ; the ‘FROM’ clause identifies the table which contains the columns to be retrieved. Example: SELECT prod_name, prod_ID FROM product_master;
  • 4. The concatenation operator is used to combine string literals and/or columns and displayed in the output. The concatenation operator is ‘ || ‘. The ‘AS’ keyword is used to specify the alias name that will represent the column in the output. We can specify the alias name using the ‘AS’ operator or just by entering the alias name after the column name separated by a space while writing the ‘SELECT’ statement. (if as ‘ ‘ the string literal contains ‘ character then use q’[ string literal ]’ between || operators) EXAMPLE : SELECT DISTINCT prod_ID || ‘ is the product ‘ || prod_name AS prod_description FROM product_master ; 4 The concatenation operator ( || ) and AS keyword.
  • 5. Mathematical Operators 5 We can use mathematical operators to create expression in the ‘SELECT’ statement . The mathematical operators are : EXAMPLE: SELECT prod_name, prod_ID, prod_cost, prod_stock - prod_order AS stock_deficit , prod_sales * prod_cost AS sales_amt FROM product_master ;
  • 6. Restricting and filtering data 6 In the previous ‘SELECT’ commands all the rows of the selected columns are displayed. We can restrict the rows that are displayed by using the ‘WHERE’ clause in combination with comparison operators and logical operators. The ‘WHERE’ clause follows the ‘FROM’ clause specifies the conditions a row should satisfy to be displayed in the output. We can use logical and comparison operators to create the expression in ‘WHERE’ clause. The operators are: LOGICAL OPERATORS COMPARISIN OPERATORS
  • 7. EXAMPLES FOR COMPARISION OPERATORS 7 We shall see a few examples using the logical operators: SELECT prod_ID,prod_name,prod_cost FROM product_master WHERE prod_cost > 2000 AND prod_cost < 25000; SELECT prod_ID,prod_name,prod_cost FROM product_master WHERE prod_cost = 30000 ; SELECT prod_ID,prod_name,prod_cost FROM product_master WHERE prod_cost >= 2000 AND prod_cost <= 25000;
  • 8. EXAMPLES FOR LOGICAL OPERATORS 8 SELECT prod_ID,prod_name,prod_cost FROM product_master WHERE prod_cost > 2000 AND prod_cost < 25000; SELECT prod_ID,prod_name,prod_cost FROM product_master WHERE prod_cost > 2000 OR prod_cost < 25000; SELECT prod_ID,prod_name,prod_cost FROM product_master WHERE NOT (prod_cost =2000);
  • 9. EXAMPLES FOR BETWEEN……AND……. CONDITION AND NULL CONDITION 9 THE BETWEEN…AND CONDITION: SELECT prod_ID,prod_name,prod_cost FROM product_master WHERE prod_cost BETWEEN 2000 AND 25000; lower limit upper limit (We use the BETWEEN …AND… condition to find rows containing values in the specified range ) THE NULL CONDITION: SELECT * FROM product_master WHERE prod_sales IS NULL ; We use the IS NULL condition to find the rows containing NULL values for a particular column.
  • 10. EXAMPLES FOR LIKE and IN CONDITION 10 THE LIKE CONDITION: SELECT prod_ID,prod_name,prod_cost FROM product_master WHERE prod_name LIKE '%sofa' ; (We use the like condition when we wish to perform wildcard character pattern matching searches. In the above ‘LIKE’ condition we search for all products containing ‘sofa’ as the terminal characters and use the ‘%’ symbol which is a wildcard for multiple characters .The ‘_’ acts a a wildcard for a single character.) THE IN CONDITION: SELECT prod_ID,prod_name,prod_cost FROM product_master WHEREprod_IDIN (‘VF001’ , ’VF004’ , ’VF006’); (We use the IN condition when we wish to search for values belonging to a particular list that is specified after the IN keyword.)
  • 11. OPERATOR PRECEDENCE 11 Importance of operators decreases
  • 12. ORDER BY clause 12 The ‘ ORDER BY’ clause is use to display the rows matching the conditions in a ordered format either in ascending order (by using keyword ‘ASC’) or in the descending order (by using keyword ‘DESC’) with ascending being the default order. The rows are ordered according to the values in one or more specified rows. THE ORDER BY CLAUSE: SELECT * FROM product_master ORDER BY prod_cost ASC; SELECT * FROM product_master ORDER BY prod_cost DESC;
  • 13. THANK YOU 13 THANK YOU FOR VIEWING THIS PRESENTATION FOR MORE PRESENTATIONS AND VIDEOS ON ORACLE AND DATAMINING , please visit: www.dataminingtools.net