SlideShare una empresa de Scribd logo
1 de 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;

Más contenido relacionado

Similar 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
 
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
 

Último

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhikauryashika82
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
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
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 

Último (20)

social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
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...
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 

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;