SlideShare uma empresa Scribd logo
1 de 4
Baixar para ler offline
CHAPTER (1)
DESC            Desc emp
SELECT          Select * from emp;
                select empno, ename, job from emp;
Arthamatic      select empno, ename, sal, sal+100 from emp
Operation + -   select empno, ename, sal, (sal+100)*12 from emp
/*              select empno, ename, sal, sal-100 from emp
ALIAS           Select empno AS “employee number, ename AS “employee name” from
                emp;
CONCAT          Select empno || ‘ , ‘ || ename ||job from emp;
DISTINCT        Select distinct (deptno) from emp;
CHAPTER (2)
WHERE clause Select * from emp
             Where ename = ‘KING’
Comparison   = equal, > greater then, < less then, >= greater then equal to, <= less
operator     then equal to , <> not equal to
NULL value   Select empno, ename, nvl(comm.,0) from emp;
COMPARISION Between – select * from emp where sal between 2500 and 3000;
OPERATOR     In - select * from emp where sal in (2500,3500,4000);
% means any  Like – select * from emp where ename like ‘SMITH’
thing        % - select * from emp where ename like ‘% MI%’

AND               select * from emp where ename = ‘SMITH’ and deptno = 20;
OR                select * from emp where ename = ‘SMITH’ or sal > 2000;
NOT IN            In - select * from emp where sal NOT in (2500,3500,4000);
ORDER BY          Select * from emp order by sal;
CHAPTER (3)

                                      SINGLE ROW FUNCTIONS

THERE ARE 5 TYPES OF SINGLE ROW FUNCTIONS
CHARACTER FUNCTION
NUMBER FUNCTION
DATE FUNCTION
CONVERSION FUNCTION

GENERAL FUNCTIONS

START WITH CHARACTER FUNCTION
CHARACTER FUNCTION ALSO DIVIDE INTO TWO PARTS
A. CASE MANIPULATION FUNCTION
B. CHARACTER MANIPULATION FUNCTION

CASE MANIPULATION FUNCTION
CASE MANIPULATION FUNCTION FURTHER DIVIDE INTO 3 PARTS
1. UPPER FUNCTION 2. LOWER FUNCTION 3. INITCAP FUNCTION
NOW START WITH UPPER FUNCTION

UPPER FUNCTION CONVERT DATA INTO
CAPITAL LETTER FROM SAMLL AND INITIAL CAPITAL LETTER

example : raheel --> RAHEEL    Raheel --> RAHEEL


select ename, lower(ename), upper(ename), initcap(ename) from emp;
SELECT HIREDATE, LOWER(HIREDATE) FROM EMP;
UPPER             SELECT * FROM EMP WHERE JOB=upper('salesman');
LOWER             SELECT * FROM EMP WHERE JOB=lower('salesman');
INITCAP           SELECT * FROM EMP WHERE JOB=initcap('salesman');

                              CHARACTER MANIPULATION FUNCTIONS

THERE ARE SEVEN TYPES OF CHARACTER MANIPULATION FUNCTIONS

1. CONCAT
2. SUBSTR
3. LENGTH
4. INSTR
5. LPAD / RPAD
6 TRIM
7. REPLACE

CONCAT       SELECT CONCAT(ENAME,JOB) FROM EMP;
SUCSTR       SELECT ENAME, SUBSTR(ENAME,2,2), JOB , SUBSTR(JOB,3,5) FROM EMP
LENGTH       SELECT ENAME, LENGTH(ENAME) FROM EMP;
INSTR        SELECT ENAME , INSTR(ENAME,'A',2,1) FROM EMP;
LPAD         SELECT SAL, LPAD(SAL,10,'*') FROM EMP;
RPAD         SELECT SAL, RPAD(SAL,10,'*') FROM EMP;
TRIM         SELECT ENAME, JOB, SAL, TRIM('A' FROM ENAME) FROM EMP;
REPLACE      SELECT ENAME, REPLACE(ENAME, 'A', 'Z') FROM EMP;
NUMBER FUNCTION

THERE ARE 3 TYPES OF NUMBER FUNCTIONS

1. ROUND
2. TRUNC
3. MOD
ROUND         SELECT ROUND(8974.34592,4), ROUND(8974.34592,3), ROUND(8974.34592,2),
              ROUND(8974.34592,1) FROM DUAL;
TRUNC         SELECT TRUNC(3456.98239,4), TRUNC(3456.98239,3), TRUNC(3456.98239,2) FROM DUAL
MOD           SELECT MOD(SAL,100) , SAL FROM EMP

                                      DATE FUNCTION


(ADD DAYS IN DATE) - SELECT HIREDATE, HIREDATE+10 FROM EMP
(ADD HOURS IN DATE) - SELECT ENAME, HIREDATE, HIREDATE+6/24 "INCREASE HOURS IN
                       HIREDATE" FROM EMP;
(ADD MINUTES IN DATE) SELECT ENAME, HIREDATE, HIREDATE+15/1440 FROM EMP
(ADD SECOND IN DATE) SELECT SYSDATE, SYSDATE+15/(24*60*60) FROM EMP;
HOW TO GET NO OF WEEKS
                       SELECT (SYSDATE-HIREDATE)/7 FROM EMP;
HOW TO GET NO OF MONTHS
                       SELECT (SYSDATE-HIREDATE)/30 FROM EMP;
NO OF YEARS            SELECT (SYSDATE-HIREDATE)/365 FROM EMP;
FINDING   NO OF DAYS NO OF WEEKS NO OF MONTH NO OF YEARS
SELECT HIREDATE, (SYSDATE-HIREDATE) "NO OF DAYS" , (SYSDATE-HIREDATE)/7 "NO OF WEEKS" ,
 (SYSDATE-HIREDATE)/30 " NO OF MONTHS " , (SYSDATE-HIREDATE)/365 " NO OF YEARS" FROM EMP;

Mais conteúdo relacionado

Semelhante a Chapter 1 (20)

Database Query Using SQL_ip.docx
Database Query Using SQL_ip.docxDatabase Query Using SQL_ip.docx
Database Query Using SQL_ip.docx
 
Les02 Restricting And Sorting Data
Les02 Restricting And Sorting DataLes02 Restricting And Sorting Data
Les02 Restricting And Sorting Data
 
Les02
Les02Les02
Les02
 
Complex queries in sql
Complex queries in sqlComplex queries in sql
Complex queries in sql
 
Sql queires
Sql queiresSql queires
Sql queires
 
Les03
Les03Les03
Les03
 
Les02
Les02Les02
Les02
 
Oracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |ThrissurOracle Training in Kochi | Trivandrum |Thrissur
Oracle Training in Kochi | Trivandrum |Thrissur
 
Sql icfai
Sql icfaiSql icfai
Sql icfai
 
Sql operators & functions 3
Sql operators & functions 3Sql operators & functions 3
Sql operators & functions 3
 
KScope19 - SQL Features
KScope19 - SQL FeaturesKScope19 - SQL Features
KScope19 - SQL Features
 
My SQL.pptx
My SQL.pptxMy SQL.pptx
My SQL.pptx
 
PLSQL Cursors
PLSQL CursorsPLSQL Cursors
PLSQL Cursors
 
COIS 420 - Practice02
COIS 420 - Practice02COIS 420 - Practice02
COIS 420 - Practice02
 
Sql queries with answers
Sql queries with answersSql queries with answers
Sql queries with answers
 
Orcl sql queries
Orcl sql queriesOrcl sql queries
Orcl sql queries
 
Sql scripting sorcerypresentation
Sql scripting sorcerypresentationSql scripting sorcerypresentation
Sql scripting sorcerypresentation
 
Oracle tips and tricks
Oracle tips and tricksOracle tips and tricks
Oracle tips and tricks
 
Restricting and sorting data
Restricting and sorting data Restricting and sorting data
Restricting and sorting data
 
chap2 (3).ppt
chap2 (3).pptchap2 (3).ppt
chap2 (3).ppt
 

Último

DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRATanmoy Mishra
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesCeline George
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsEugene Lysak
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphNetziValdelomar1
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxDr. Santhosh Kumar. N
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfTechSoup
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17Celine George
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxheathfieldcps1
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 

Último (20)

DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRADUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
DUST OF SNOW_BY ROBERT FROST_EDITED BY_ TANMOY MISHRA
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024
 
How to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 SalesHow to Manage Cross-Selling in Odoo 17 Sales
How to Manage Cross-Selling in Odoo 17 Sales
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George Wells
 
Presentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a ParagraphPresentation on the Basics of Writing. Writing a Paragraph
Presentation on the Basics of Writing. Writing a Paragraph
 
M-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptxM-2- General Reactions of amino acids.pptx
M-2- General Reactions of amino acids.pptx
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
The basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptxThe basics of sentences session 10pptx.pptx
The basics of sentences session 10pptx.pptx
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 

Chapter 1

  • 1. CHAPTER (1) DESC Desc emp SELECT Select * from emp; select empno, ename, job from emp; Arthamatic select empno, ename, sal, sal+100 from emp Operation + - select empno, ename, sal, (sal+100)*12 from emp /* select empno, ename, sal, sal-100 from emp ALIAS Select empno AS “employee number, ename AS “employee name” from emp; CONCAT Select empno || ‘ , ‘ || ename ||job from emp; DISTINCT Select distinct (deptno) from emp;
  • 2. CHAPTER (2) WHERE clause Select * from emp Where ename = ‘KING’ Comparison = equal, > greater then, < less then, >= greater then equal to, <= less operator then equal to , <> not equal to NULL value Select empno, ename, nvl(comm.,0) from emp; COMPARISION Between – select * from emp where sal between 2500 and 3000; OPERATOR In - select * from emp where sal in (2500,3500,4000); % means any Like – select * from emp where ename like ‘SMITH’ thing % - select * from emp where ename like ‘% MI%’ AND select * from emp where ename = ‘SMITH’ and deptno = 20; OR select * from emp where ename = ‘SMITH’ or sal > 2000; NOT IN In - select * from emp where sal NOT in (2500,3500,4000); ORDER BY Select * from emp order by sal;
  • 3. CHAPTER (3) SINGLE ROW FUNCTIONS THERE ARE 5 TYPES OF SINGLE ROW FUNCTIONS CHARACTER FUNCTION NUMBER FUNCTION DATE FUNCTION CONVERSION FUNCTION GENERAL FUNCTIONS START WITH CHARACTER FUNCTION CHARACTER FUNCTION ALSO DIVIDE INTO TWO PARTS A. CASE MANIPULATION FUNCTION B. CHARACTER MANIPULATION FUNCTION CASE MANIPULATION FUNCTION CASE MANIPULATION FUNCTION FURTHER DIVIDE INTO 3 PARTS 1. UPPER FUNCTION 2. LOWER FUNCTION 3. INITCAP FUNCTION NOW START WITH UPPER FUNCTION UPPER FUNCTION CONVERT DATA INTO CAPITAL LETTER FROM SAMLL AND INITIAL CAPITAL LETTER example : raheel --> RAHEEL Raheel --> RAHEEL select ename, lower(ename), upper(ename), initcap(ename) from emp; SELECT HIREDATE, LOWER(HIREDATE) FROM EMP; UPPER SELECT * FROM EMP WHERE JOB=upper('salesman'); LOWER SELECT * FROM EMP WHERE JOB=lower('salesman'); INITCAP SELECT * FROM EMP WHERE JOB=initcap('salesman'); CHARACTER MANIPULATION FUNCTIONS THERE ARE SEVEN TYPES OF CHARACTER MANIPULATION FUNCTIONS 1. CONCAT 2. SUBSTR 3. LENGTH 4. INSTR 5. LPAD / RPAD 6 TRIM 7. REPLACE CONCAT SELECT CONCAT(ENAME,JOB) FROM EMP; SUCSTR SELECT ENAME, SUBSTR(ENAME,2,2), JOB , SUBSTR(JOB,3,5) FROM EMP LENGTH SELECT ENAME, LENGTH(ENAME) FROM EMP; INSTR SELECT ENAME , INSTR(ENAME,'A',2,1) FROM EMP; LPAD SELECT SAL, LPAD(SAL,10,'*') FROM EMP; RPAD SELECT SAL, RPAD(SAL,10,'*') FROM EMP; TRIM SELECT ENAME, JOB, SAL, TRIM('A' FROM ENAME) FROM EMP; REPLACE SELECT ENAME, REPLACE(ENAME, 'A', 'Z') FROM EMP;
  • 4. NUMBER FUNCTION THERE ARE 3 TYPES OF NUMBER FUNCTIONS 1. ROUND 2. TRUNC 3. MOD ROUND SELECT ROUND(8974.34592,4), ROUND(8974.34592,3), ROUND(8974.34592,2), ROUND(8974.34592,1) FROM DUAL; TRUNC SELECT TRUNC(3456.98239,4), TRUNC(3456.98239,3), TRUNC(3456.98239,2) FROM DUAL MOD SELECT MOD(SAL,100) , SAL FROM EMP DATE FUNCTION (ADD DAYS IN DATE) - SELECT HIREDATE, HIREDATE+10 FROM EMP (ADD HOURS IN DATE) - SELECT ENAME, HIREDATE, HIREDATE+6/24 "INCREASE HOURS IN HIREDATE" FROM EMP; (ADD MINUTES IN DATE) SELECT ENAME, HIREDATE, HIREDATE+15/1440 FROM EMP (ADD SECOND IN DATE) SELECT SYSDATE, SYSDATE+15/(24*60*60) FROM EMP; HOW TO GET NO OF WEEKS SELECT (SYSDATE-HIREDATE)/7 FROM EMP; HOW TO GET NO OF MONTHS SELECT (SYSDATE-HIREDATE)/30 FROM EMP; NO OF YEARS SELECT (SYSDATE-HIREDATE)/365 FROM EMP; FINDING NO OF DAYS NO OF WEEKS NO OF MONTH NO OF YEARS SELECT HIREDATE, (SYSDATE-HIREDATE) "NO OF DAYS" , (SYSDATE-HIREDATE)/7 "NO OF WEEKS" , (SYSDATE-HIREDATE)/30 " NO OF MONTHS " , (SYSDATE-HIREDATE)/365 " NO OF YEARS" FROM EMP;