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

DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
Ashwin Dinoriya
 
Avinash database
Avinash databaseAvinash database
Avinash database
avibmas
 

What's hot (18)

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)
 
Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)Database Systems - SQL - DDL Statements (Chapter 3/2)
Database Systems - SQL - DDL Statements (Chapter 3/2)
 
Lab2 ddl commands
Lab2 ddl commandsLab2 ddl commands
Lab2 ddl commands
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 
DDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and JoinsDDL,DML,SQL Functions and Joins
DDL,DML,SQL Functions and Joins
 
Lab1 select statement
Lab1 select statementLab1 select statement
Lab1 select statement
 
Avinash database
Avinash databaseAvinash database
Avinash database
 
Sql
SqlSql
Sql
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)Database Systems - SQL - DCL Statements (Chapter 3/4)
Database Systems - SQL - DCL Statements (Chapter 3/4)
 
Oracle SQL DML Statements
Oracle SQL DML StatementsOracle SQL DML Statements
Oracle SQL DML Statements
 
Sql commands
Sql commandsSql commands
Sql commands
 
SQL - Structured query language introduction
SQL - Structured query language introductionSQL - Structured query language introduction
SQL - Structured query language introduction
 
Nested Queries Lecture
Nested Queries LectureNested Queries Lecture
Nested Queries Lecture
 
SQL Server Views
SQL Server ViewsSQL Server Views
SQL Server Views
 
Oracle basic queries
Oracle basic queriesOracle basic queries
Oracle basic queries
 
Oracle: DDL
Oracle: DDLOracle: DDL
Oracle: DDL
 
Mysql cheatsheet
Mysql cheatsheetMysql cheatsheet
Mysql cheatsheet
 

Viewers also liked

Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
honglee71
 
Oracle 10g sql fundamentals i
Oracle 10g sql fundamentals iOracle 10g sql fundamentals i
Oracle 10g sql fundamentals i
Manaswi Sharma
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
Anurag
 

Viewers also liked (20)

Oracle Database Overview
Oracle Database OverviewOracle Database Overview
Oracle Database Overview
 
Présentation Oracle DataBase 11g
Présentation Oracle DataBase 11gPrésentation Oracle DataBase 11g
Présentation Oracle DataBase 11g
 
Sql Objects And PL/SQL
Sql Objects And PL/SQLSql Objects And PL/SQL
Sql Objects And PL/SQL
 
Basic Oracle Usage v1
Basic Oracle Usage v1Basic Oracle Usage v1
Basic Oracle Usage v1
 
Oracle SQL Basics by Ankur Raina
Oracle SQL Basics by Ankur RainaOracle SQL Basics by Ankur Raina
Oracle SQL Basics by Ankur Raina
 
Basic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database AdministratorsBasic MySQL Troubleshooting for Oracle Database Administrators
Basic MySQL Troubleshooting for Oracle Database Administrators
 
Introduction To Oracle Sql
Introduction To Oracle SqlIntroduction To Oracle Sql
Introduction To Oracle Sql
 
Basic of Oracle Application
Basic of Oracle ApplicationBasic of Oracle Application
Basic of Oracle Application
 
Oracle Database Management Basic 1
Oracle Database Management Basic 1Oracle Database Management Basic 1
Oracle Database Management Basic 1
 
Oracle 10g sql fundamentals i
Oracle 10g sql fundamentals iOracle 10g sql fundamentals i
Oracle 10g sql fundamentals i
 
8. sql
8. sql8. sql
8. sql
 
Oracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creationsOracle architecture with details-yogiji creations
Oracle architecture with details-yogiji creations
 
Introduction to Oracle Database
Introduction to Oracle DatabaseIntroduction to Oracle Database
Introduction to Oracle Database
 
Oracle sql tutorial
Oracle sql tutorialOracle sql tutorial
Oracle sql tutorial
 
ORACLE PL SQL
ORACLE PL SQLORACLE PL SQL
ORACLE PL SQL
 
Basic oracle-database-administration
Basic oracle-database-administrationBasic oracle-database-administration
Basic oracle-database-administration
 
Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
Creating database
Creating databaseCreating database
Creating database
 
Oracle Essentials Oracle Database 11g
Oracle Essentials   Oracle Database 11gOracle Essentials   Oracle Database 11g
Oracle Essentials Oracle Database 11g
 
Oracle sql & plsql
Oracle sql & plsqlOracle sql & plsql
Oracle sql & plsql
 

Similar to Oracle: Basic SQL

Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
Achmad Solichin
 
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
 

Similar to 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
 
Les18
Les18Les18
Les18
 
75864 sql
75864 sql75864 sql
75864 sql
 
Les02
Les02Les02
Les02
 
Module03
Module03Module03
Module03
 
Les02 (restricting and sorting data)
Les02 (restricting and sorting data)Les02 (restricting and sorting data)
Les02 (restricting and sorting data)
 
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
 

More from DataminingTools Inc

More from DataminingTools Inc (20)

Terminology Machine Learning
Terminology Machine LearningTerminology Machine Learning
Terminology Machine Learning
 
Techniques Machine Learning
Techniques Machine LearningTechniques Machine Learning
Techniques Machine Learning
 
Machine learning Introduction
Machine learning IntroductionMachine learning Introduction
Machine learning Introduction
 
Areas of machine leanring
Areas of machine leanringAreas of machine leanring
Areas of machine leanring
 
AI: Planning and AI
AI: Planning and AIAI: Planning and AI
AI: Planning and AI
 
AI: Logic in AI 2
AI: Logic in AI 2AI: Logic in AI 2
AI: Logic in AI 2
 
AI: Logic in AI
AI: Logic in AIAI: Logic in AI
AI: Logic in AI
 
AI: Learning in AI 2
AI: Learning in AI 2AI: Learning in AI 2
AI: Learning in AI 2
 
AI: Learning in AI
AI: Learning in AI AI: Learning in AI
AI: Learning in AI
 
AI: Introduction to artificial intelligence
AI: Introduction to artificial intelligenceAI: Introduction to artificial intelligence
AI: Introduction to artificial intelligence
 
AI: Belief Networks
AI: Belief NetworksAI: Belief Networks
AI: Belief Networks
 
AI: AI & Searching
AI: AI & SearchingAI: AI & Searching
AI: AI & Searching
 
AI: AI & Problem Solving
AI: AI & Problem SolvingAI: AI & Problem Solving
AI: AI & Problem Solving
 
Data Mining: Text and web mining
Data Mining: Text and web miningData Mining: Text and web mining
Data Mining: Text and web mining
 
Data Mining: Outlier analysis
Data Mining: Outlier analysisData Mining: Outlier analysis
Data Mining: Outlier analysis
 
Data Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence dataData Mining: Mining stream time series and sequence data
Data Mining: Mining stream time series and sequence data
 
Data Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlationsData Mining: Mining ,associations, and correlations
Data Mining: Mining ,associations, and correlations
 
Data Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysisData Mining: Graph mining and social network analysis
Data Mining: Graph mining and social network analysis
 
Data warehouse and olap technology
Data warehouse and olap technologyData warehouse and olap technology
Data warehouse and olap technology
 
Data Mining: Data processing
Data Mining: Data processingData Mining: Data processing
Data Mining: Data processing
 

Recently uploaded

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Recently uploaded (20)

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...
 
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
 
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...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
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
 
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
 

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