SlideShare a Scribd company logo
1 of 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

More Related Content

What's hot

SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functionsVikas Gupta
 
SQL Functions and Operators
SQL Functions and OperatorsSQL Functions and Operators
SQL Functions and OperatorsMohan Kumar.R
 
Advanced Sql Training
Advanced Sql TrainingAdvanced Sql Training
Advanced Sql Trainingbixxman
 
Advanced SQL Webinar
Advanced SQL WebinarAdvanced SQL Webinar
Advanced SQL WebinarRam Kedem
 
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 statementSyed Zaid Irshad
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Achmad Solichin
 
1. dml select statement reterive data
1. dml select statement reterive data1. dml select statement reterive data
1. dml select statement reterive dataAmrit Kaur
 
STRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESSTRUCTURE OF SQL QUERIES
STRUCTURE OF SQL QUERIESVENNILAV6
 
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
 
Where conditions and Operators in SQL
Where conditions and Operators in SQLWhere conditions and Operators in SQL
Where conditions and Operators in SQLRaajendra M
 
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 10Thuan Nguyen
 

What's hot (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
 

Similar to Introduction to SELECT clause and writing basic advanced SELECT statements

Similar to Introduction to SELECT clause and writing basic advanced SELECT statements (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
 

More from oracle content

More from 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
 

Recently uploaded

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

Recently uploaded (20)

Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 

Introduction to SELECT clause and writing basic advanced SELECT statements

  • 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