SlideShare ist ein Scribd-Unternehmen logo
1 von 4
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;

Weitere ähnliche Inhalte

Ähnlich wie 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
 
21390228-SQL-Queries.doc
21390228-SQL-Queries.doc21390228-SQL-Queries.doc
21390228-SQL-Queries.doc
 
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
 

Kürzlich hochgeladen

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxcallscotland1987
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701bronxfugly43
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxAmita Gupta
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxnegromaestrong
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfPoh-Sun Goh
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfAdmir Softic
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 

Kürzlich hochgeladen (20)

microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Third Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptxThird Battle of Panipat detailed notes.pptx
Third Battle of Panipat detailed notes.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Seal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptxSeal of Good Local Governance (SGLG) 2024Final.pptx
Seal of Good Local Governance (SGLG) 2024Final.pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 

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;