SlideShare une entreprise Scribd logo
1  sur  69
 
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],SQL ADVANCED ,[object Object],[object Object],[object Object],[object Object],[object Object]
Introduction to SQL ,[object Object],[object Object],What is SQL? ,[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object]
[object Object],[object Object],[object Object]
[object Object],[object Object],CREATE DATABASE database_name   ,[object Object],[object Object],CREATE TABLE table_name ( column_name1 data_type,  column_name2 data_type, ....... )   SQL Create The  CREATE  statement is used to create a new database, table or index.
Some Basic Data Types SQL Create Data Type Description integer (size) int (size) smallint (size) tinyint (size) Hold integers only. The maximum number of digits are specified in parenthesis. Decimal (size, d) numeric (size, d) Hold numbers with fractions. The maximum number of digits are specified in "size". The maximum number of digits to the right of the decimal is specified in "d".
Some Basic Data Types (cont.) SQL Create char (size) Holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis. varchar (size) Holds a variable length string (can contain letters, numbers, and special characters). The maximum size is specified in parenthesis. date (yyyymmdd) Holds a date
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
ALTER Statement
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
DROP Statement
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
INSERT Statement
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
UPDATE Statement
[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object]
DELETE Statement
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
SELECT Statement
[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object],[object Object],[object Object]
[object Object],[object Object],[object Object]
Selection Projection Table 1 Table 2 Table 1 Table 1 Join
[object Object],[object Object],SELECT [DISTINCT] {*,  column  [ alias ],...} FROM table;
[object Object],[object Object],[object Object],[object Object],[object Object]
DEPTNO DNAME  LOC --------- -------------- ------------- 10 ACCOUNTING  MALOLOS 20 RESEARCH  HAGONOY 30 SALES  CALUMPIT 40 OPERATIONS  PULILAN SQL> SELECT * 2  FROM  dept;
DEPTNO LOC --------- ------------- 10 MALOLOS 20 HAGONOY 30 CALUMPIT 40 PULILAN SQL> SELECT deptno, loc 2  FROM  dept;
[object Object],Operator + - * /  Description Add Subtract  Multiply  Divide
SQL> SELECT ename, sal, sal+300 2  FROM emp; ENAME  SAL  SAL+300 ---------- --------- --------- ROMEL 20000   20300 JOI 10000   10300 JANE 5000   5300 ANDY 5875  6175 RANDY 11784   12084 MARK 9775   10075 ... 10 rows selected.
[object Object],[object Object],[object Object],* / + _
SQL> SELECT ename, sal, 12*sal+100 2  FROM  emp; ENAME  SAL 12*SAL+100 ---------- --------- ---------- ROMEL 20000   240100 JOI 10000   120100 JANE 5000   60100 ANDY 5875  70600 RANDY 11784   141508 ... 10 rows selected.
SQL> SELECT ename, sal, 12*(sal+100) 2  FROM  emp; ENAME  SAL 12*(SAL+100) ---------- --------- ----------- ROMEL 20000   241200 JOI 10000   121200 JANE 5000   61200 ANDY 5875  71700 RANDY 11784   142608 ... 10 rows selected.
[object Object],[object Object],ENAME  JOB  SAL  COMM ---------- --------- --------- --------- ROMEL   PRESIDENT 20000   NULL JOI   SALES MANAGER 10000   1000 ... RANDY   HEAD ACCOUNTANT 11784   NULL 10 rows selected. SQL> SELECT ename, job, sal, comm 2  FROM  emp;
[object Object],SQL> select ename, 12*sal+comm  2  from  emp 3  WHERE  ename=‘ROMEL'; ENAME  12*SAL+COMM  ---------- ----------- KING NULL
[object Object],[object Object],[object Object],[object Object]
SQL> SELECT ename AS name, sal salary 2  FROM  emp; NAME  SALARY ------------- --------- ... SQL> SELECT ename  "Name", 2  sal*12 "Annual Salary" 3  FROM  emp; Name  Annual Salary ------------- ------------- ...
[object Object],[object Object],[object Object]
SQL> SELECT ename + job AS "Employees" 2  FROM  emp; Employees ------------------- ROMELPRESIDENT JOISALES MANAGER JANESALES REPRESENTATIVE ANDYSALES REPRESENTATIVE RANDYHEAD ACCOUNTANT ... 10 rows selected.
[object Object],[object Object],[object Object]
Employee Details ------------------------- ... 10 rows selected. SQL> SELECT ename + ' is a ‘ + job  2   AS "Employee Details" 3  FROM  emp; ROMEL is a PRESIDENT JOI is a SALES MANAGER JANE is a SALES REPRESENTATIVE ANDY is a SALES REPRESENTATIVE RANDY is a HEAD ACCOUNTANT
[object Object],SQL> SELECT deptno 2  FROM  emp; DEPTNO --------- 10 30 10 40 ... 14 rows selected.
Eliminate duplicate rows by using the DISTINCT keyword in the SELECT clause. SQL> SELECT DISTINCT deptno 2  FROM  emp; DEPTNO --------- 10 30 40
SQL statements ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],SQL buffer SQL*Plus commands SQL*Plus buffer
"…retrieve all employees in department 30" EMP EMPNO  ENAME  JOB  ...  DEPTNO  1001 ROMEL PRESIDENT   40 1002 JOI SALES M...  30 1003 JANE SALES REP    30 . . . 1006 MARK ACCOUN..   10   ... EMP EMPNO  ENAME  JOB  ...  DEPTNO  1002 JOI SALES M...  30 1003 JANE SALES REP    30 . . .
[object Object],[object Object],SELECT [DISTINCT] {*|  column  [ alias ], ...} FROM  table [WHERE condition(s) ];
SQL> SELECT ename, deptno 2  FROM  emp 3  WHERE  deptno=10; ENAME  DEPTNO ---------- --------- --------- RANDY   10 MARK   10 JESSA   10
Operator = > >= < <= <> Meaning Equal to Greater than  Greater than or equal to  Less than  Less than or equal to Not equal to
SQL> SELECT ename,comm 2  FROM  emp 3  WHERE  comm>=700; ENAME  COMM ---------- ---------  MARTIN  1000
Operator BETWEEN ...AND... IN(list) LIKE IS NULL Meaning Between two values (inclusive) Match any of a list of values  Match a character pattern  Is a null value
[object Object],ENAME  SAL ---------- --------- JOI 10000 JANE 5000 ANDY 5875 MARK 9775 RIZZA 9798 DAVID 6897 SQL> SELECT ename, sal 2  FROM  emp 3  WHERE sal BETWEEN 5000 AND 10000; Lower limit Higher limit
[object Object],SQL> SELECT ename, deptno 2  FROM  emp 3  WHERE deptno IN (10, 40);   ENAME  deptno ---------  ---------   ROMEL   40   RANDY   10   MARK   10   RIZZA   40
[object Object],[object Object],[object Object],[object Object],SQL> SELECT ename 2  FROM  emp 3  WHERE ename LIKE ‘R%';
[object Object],[object Object],SQL> SELECT ename 2  FROM emp 3  WHERE ename LIKE '_O%'; ENAME ----------  ROMEL JOI
[object Object],SQL> SELECT  ename, mgr 2  FROM  emp 3  WHERE  mgr IS NULL; ENAME  MGR ---------- --------- ROMEL NULL
Operator AND OR NOT Meaning Returns TRUE if  both  component conditions are TRUE Returns TRUE if  either  component condition is TRUE Returns TRUE if the following  condition is FALSE

Contenu connexe

Tendances (20)

Ppt INFORMATIVE PRACTICES for class 11th chapter 14
Ppt INFORMATIVE PRACTICES for class 11th chapter 14Ppt INFORMATIVE PRACTICES for class 11th chapter 14
Ppt INFORMATIVE PRACTICES for class 11th chapter 14
 
Query
QueryQuery
Query
 
Les00 Intoduction
Les00 IntoductionLes00 Intoduction
Les00 Intoduction
 
Dbms record
Dbms recordDbms record
Dbms record
 
Lecture 4 sql {basics keys and constraints}
Lecture 4 sql {basics  keys and constraints}Lecture 4 sql {basics  keys and constraints}
Lecture 4 sql {basics keys and constraints}
 
DBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) pptDBMS information in detail || Dbms (lab) ppt
DBMS information in detail || Dbms (lab) ppt
 
Les01 Writing Basic Sql Statements
Les01 Writing Basic Sql StatementsLes01 Writing Basic Sql Statements
Les01 Writing Basic Sql Statements
 
Les03 Single Row Function
Les03 Single Row FunctionLes03 Single Row Function
Les03 Single Row Function
 
Les02
Les02Les02
Les02
 
MY SQL
MY SQLMY SQL
MY SQL
 
Sql
SqlSql
Sql
 
Sql practise for beginners
Sql practise for beginnersSql practise for beginners
Sql practise for beginners
 
Lecture 3 sql {basics ddl commands}
Lecture 3 sql {basics  ddl commands}Lecture 3 sql {basics  ddl commands}
Lecture 3 sql {basics ddl commands}
 
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)
 
Les02
Les02Les02
Les02
 
dbms lab manual
dbms lab manualdbms lab manual
dbms lab manual
 
Db1 lecture4
Db1 lecture4Db1 lecture4
Db1 lecture4
 
Sql
SqlSql
Sql
 
Les13
Les13Les13
Les13
 
Les04 Displaying Data From Multiple Table
Les04 Displaying Data From Multiple TableLes04 Displaying Data From Multiple Table
Les04 Displaying Data From Multiple Table
 

Similaire à Select To Order By (20)

Les01
Les01Les01
Les01
 
Les01
Les01Les01
Les01
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
Les09
Les09Les09
Les09
 
Les01-Oracle
Les01-OracleLes01-Oracle
Les01-Oracle
 
Database Management System
Database Management SystemDatabase Management System
Database Management System
 
Beginers guide for oracle sql
Beginers guide for oracle sqlBeginers guide for oracle sql
Beginers guide for oracle sql
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Creating database using sql commands
Creating database using sql commandsCreating database using sql commands
Creating database using sql commands
 
Les10
Les10Les10
Les10
 
Sql intro
Sql introSql intro
Sql intro
 
Oraclesql
OraclesqlOraclesql
Oraclesql
 
SQL Overview
SQL OverviewSQL Overview
SQL Overview
 
Sql
SqlSql
Sql
 
SQL
SQLSQL
SQL
 
chapter 8 SQL.ppt
chapter 8 SQL.pptchapter 8 SQL.ppt
chapter 8 SQL.ppt
 
Mysqlppt
MysqlpptMysqlppt
Mysqlppt
 
SQL (1).pptx
SQL (1).pptxSQL (1).pptx
SQL (1).pptx
 
Basic SQL Statments
Basic SQL StatmentsBasic SQL Statments
Basic SQL Statments
 
Les09 Manipulating Data
Les09 Manipulating DataLes09 Manipulating Data
Les09 Manipulating Data
 

Dernier

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
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 WorkerThousandEyes
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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
 

Dernier (20)

Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
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
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
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
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
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
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 

Select To Order By

  • 1.  
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. Some Basic Data Types SQL Create Data Type Description integer (size) int (size) smallint (size) tinyint (size) Hold integers only. The maximum number of digits are specified in parenthesis. Decimal (size, d) numeric (size, d) Hold numbers with fractions. The maximum number of digits are specified in &quot;size&quot;. The maximum number of digits to the right of the decimal is specified in &quot;d&quot;.
  • 11. Some Basic Data Types (cont.) SQL Create char (size) Holds a fixed length string (can contain letters, numbers, and special characters). The fixed size is specified in parenthesis. varchar (size) Holds a variable length string (can contain letters, numbers, and special characters). The maximum size is specified in parenthesis. date (yyyymmdd) Holds a date
  • 12.
  • 13.
  • 14.
  • 15.
  • 17.
  • 18.
  • 20.
  • 21.
  • 23.
  • 24.
  • 25.
  • 27.
  • 28.
  • 30.
  • 31.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37. Selection Projection Table 1 Table 2 Table 1 Table 1 Join
  • 38.
  • 39.
  • 40. DEPTNO DNAME LOC --------- -------------- ------------- 10 ACCOUNTING MALOLOS 20 RESEARCH HAGONOY 30 SALES CALUMPIT 40 OPERATIONS PULILAN SQL> SELECT * 2 FROM dept;
  • 41. DEPTNO LOC --------- ------------- 10 MALOLOS 20 HAGONOY 30 CALUMPIT 40 PULILAN SQL> SELECT deptno, loc 2 FROM dept;
  • 42.
  • 43. SQL> SELECT ename, sal, sal+300 2 FROM emp; ENAME SAL SAL+300 ---------- --------- --------- ROMEL 20000 20300 JOI 10000 10300 JANE 5000 5300 ANDY 5875 6175 RANDY 11784 12084 MARK 9775 10075 ... 10 rows selected.
  • 44.
  • 45. SQL> SELECT ename, sal, 12*sal+100 2 FROM emp; ENAME SAL 12*SAL+100 ---------- --------- ---------- ROMEL 20000 240100 JOI 10000 120100 JANE 5000 60100 ANDY 5875 70600 RANDY 11784 141508 ... 10 rows selected.
  • 46. SQL> SELECT ename, sal, 12*(sal+100) 2 FROM emp; ENAME SAL 12*(SAL+100) ---------- --------- ----------- ROMEL 20000 241200 JOI 10000 121200 JANE 5000 61200 ANDY 5875 71700 RANDY 11784 142608 ... 10 rows selected.
  • 47.
  • 48.
  • 49.
  • 50. SQL> SELECT ename AS name, sal salary 2 FROM emp; NAME SALARY ------------- --------- ... SQL> SELECT ename &quot;Name&quot;, 2 sal*12 &quot;Annual Salary&quot; 3 FROM emp; Name Annual Salary ------------- ------------- ...
  • 51.
  • 52. SQL> SELECT ename + job AS &quot;Employees&quot; 2 FROM emp; Employees ------------------- ROMELPRESIDENT JOISALES MANAGER JANESALES REPRESENTATIVE ANDYSALES REPRESENTATIVE RANDYHEAD ACCOUNTANT ... 10 rows selected.
  • 53.
  • 54. Employee Details ------------------------- ... 10 rows selected. SQL> SELECT ename + ' is a ‘ + job 2 AS &quot;Employee Details&quot; 3 FROM emp; ROMEL is a PRESIDENT JOI is a SALES MANAGER JANE is a SALES REPRESENTATIVE ANDY is a SALES REPRESENTATIVE RANDY is a HEAD ACCOUNTANT
  • 55.
  • 56. Eliminate duplicate rows by using the DISTINCT keyword in the SELECT clause. SQL> SELECT DISTINCT deptno 2 FROM emp; DEPTNO --------- 10 30 40
  • 57.
  • 58. &quot;…retrieve all employees in department 30&quot; EMP EMPNO ENAME JOB ... DEPTNO 1001 ROMEL PRESIDENT 40 1002 JOI SALES M... 30 1003 JANE SALES REP 30 . . . 1006 MARK ACCOUN.. 10 ... EMP EMPNO ENAME JOB ... DEPTNO 1002 JOI SALES M... 30 1003 JANE SALES REP 30 . . .
  • 59.
  • 60. SQL> SELECT ename, deptno 2 FROM emp 3 WHERE deptno=10; ENAME DEPTNO ---------- --------- --------- RANDY 10 MARK 10 JESSA 10
  • 61. Operator = > >= < <= <> Meaning Equal to Greater than Greater than or equal to Less than Less than or equal to Not equal to
  • 62. SQL> SELECT ename,comm 2 FROM emp 3 WHERE comm>=700; ENAME COMM ---------- --------- MARTIN 1000
  • 63. Operator BETWEEN ...AND... IN(list) LIKE IS NULL Meaning Between two values (inclusive) Match any of a list of values Match a character pattern Is a null value
  • 64.
  • 65.
  • 66.
  • 67.
  • 68.
  • 69. Operator AND OR NOT Meaning Returns TRUE if both component conditions are TRUE Returns TRUE if either component condition is TRUE Returns TRUE if the following condition is FALSE