SlideShare una empresa de Scribd logo
1 de 24
8-1   Copyright © 2004, Oracle. All rights reserved.
Using the NVL Function

      ex1:- To calculate the annual compensation of all employees, you need to
      multiply the monthly salary by 12 and then add the commission percentage
      to the result

      SELECT last_name, salary, NVL(commission_pct, 0),
         (salary*12) + (salary*12*NVL(commission_pct, 0)) AN_SAL
      FROM employees;




       .
       .




8-2                        Copyright © 2004, Oracle. All rights reserved.
Using the NVL2 Function


      SELECT last_name, salary, commission_pct,
             NVL2(commission_pct,'SAL+COMM', 'SAL') income
      FROM   employees WHERE department_id IN (50, 80);




       .
       .




8-3                     Copyright © 2004, Oracle. All rights reserved.
Executing Single-Row Subqueries

      ex1:- displays employees whose job ID is the same as that of employee
      141 and whose salary is greater than that of employee 143.

      SELECT last_name, job_id, salary
      FROM   employees
      WHERE job_id =                 ST_CLERK
                      (SELECT job_id
                       FROM   employees
                       WHERE employee_id = 141)
      AND    salary >                   2600
                      (SELECT salary
                       FROM   employees
                       WHERE employee_id = 143);



          The result in next slide



8-4                       Copyright © 2004, Oracle. All rights reserved.
8-5   Copyright © 2004, Oracle. All rights reserved.
Executing Single-Row Subqueries

      ex2:- Find the job with the lowest average salary.


       SELECT      job_id, AVG(salary)
       FROM        employees
       GROUP BY    job_id
       HAVING      AVG(salary)=(SELECT MIN(AVG(salary))
                                FROM     employees
                                GROUP BY job_id);




8-6                         Copyright © 2004, Oracle. All rights reserved.
Will This Statement Return Rows?

      SELECT last_name, job_id
      FROM   employees
      WHERE job_id =
                      (SELECT job_id
                       FROM   employees
                       WHERE last_name = 'Haas');




      there is no employee named Haas. So the subquery returns no
      rows
      The outer query takes the results of the subquery (null) and uses
      these results in its WHERE clause.
      The outer query finds no employee with a job ID equal to null, and
      so returns no rows



8-7                      Copyright © 2004, Oracle. All rights reserved.
Executing multiple-Row Subqueries

      ex3:- display the employees whose there salary equal to the min salary of
      each department.


      SELECT last_name, salary, department_id
      FROM   employees
      WHERE salary IN (SELECT    MIN(salary)
                        FROM     employees
                        GROUP BY department_id);




            The result in next slide




8-8                        Copyright © 2004, Oracle. All rights reserved.
8-9   Copyright © 2004, Oracle. All rights reserved.
Executing multiple-Row Subqueries

       ex4:- displays employees who are not IT programmers and whose salary
       is less than that of any IT programmer.

       SELECT employee_id, last_name, job_id, salary
       FROM   employees    9000, 6000, 4800,4200
       WHERE salary < ANY
                           (SELECT distinct salary
                            FROM         employees
                            WHERE job_id = 'IT_PROG')
       AND    job_id <> 'IT_PROG';

       =ANY is equivalent to IN.
       >ANY means more than the minimum.
       <ANY means less than the maximum

             The result in next slide




8-10                         Copyright © 2004, Oracle. All rights reserved.
.
       .




8-11       Copyright © 2004, Oracle. All rights reserved.
Executing multiple-Row Subqueries

       ex4:- displays employees who are not IT programmers and whose salary
       is less than that of all IT programmer.

       SELECT employee_id, last_name, job_id, salary
       FROM   employees    9000, 6000, 4800,4200
       WHERE salary < ALL
                           (SELECT distinct salary
                            FROM         employees
                            WHERE job_id = 'IT_PROG')
       AND    job_id <> 'IT_PROG';

       >ALL means more than the maximum
       <ALL means less than the minimum
             The result in next slide




8-12                         Copyright © 2004, Oracle. All rights reserved.
.
           .




       .
       .




8-13           Copyright © 2004, Oracle. All rights reserved.
Create a query that displays the first eight characters of the employees’ last
names and indicates the amounts of their salaries with stars. Each star
signifies a thousand dollars. Sort the data in descending order of salary.
Label the column EMPLOYEES_AND_THEIR_SALARIES.




  8-14                   Copyright © 2004, Oracle. All rights reserved.
8-15   Copyright © 2004, Oracle. All rights reserved.
8-16   Copyright © 2004, Oracle. All rights reserved.
8-17   Copyright © 2004, Oracle. All rights reserved.
The function check_sal is written to check if the salary of a
 particular employee is greater or less than the average salary of all
 employees working in his department. The function returns TRUE if
 the salary of the employee is greater than the average salary of
 employees in his department else returns FALSE. The function
 returns NULL if a NO_DATA_FOUND exception is thrown.




8-18                   Copyright © 2004, Oracle. All rights reserved.
8-19   Copyright © 2004, Oracle. All rights reserved.
Observe that the function checks for the employee with the
  employee ID 205. The function is hard coded to check for this
  employee ID only. If you want to check for any other employees,
  you will have to modify the function itself. You can solve this
  problem by declaring the function such that it accepts an
  argument. You can then pass the employee ID as parameter.




8-20                  Copyright © 2004, Oracle. All rights reserved.
8-21   Copyright © 2004, Oracle. All rights reserved.
8-22   Copyright © 2004, Oracle. All rights reserved.
8-23   Copyright © 2004, Oracle. All rights reserved.
8-24   Copyright © 2004, Oracle. All rights reserved.

Más contenido relacionado

Destacado

SRS Document Of Course management software system.doc
SRS Document Of Course management software system.docSRS Document Of Course management software system.doc
SRS Document Of Course management software system.docMaRwa Samih AL-Amri
 
Examples of sql queries
Examples of sql queriesExamples of sql queries
Examples of sql queriesKishan Pant
 
Lotus Admin Training Part I
Lotus Admin Training Part ILotus Admin Training Part I
Lotus Admin Training Part ISanjaya K Saxena
 
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notesHow to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notesandrewscott01
 
example of sql injection
example of sql injectionexample of sql injection
example of sql injectionCARMEN ALCIVAR
 
Overview of lotus notes/domino 8.5
Overview of lotus notes/domino 8.5Overview of lotus notes/domino 8.5
Overview of lotus notes/domino 8.5Nilabh Verma
 
Lotus Notes Client Troubleshooting
Lotus Notes Client TroubleshootingLotus Notes Client Troubleshooting
Lotus Notes Client Troubleshootingharirajtyagi
 
IBM Lotus Notes Clients - Differences
IBM Lotus Notes Clients - DifferencesIBM Lotus Notes Clients - Differences
IBM Lotus Notes Clients - DifferencesDvir Reznik
 
Introducing IBM Lotus Notes and Domino 8.5
Introducing IBM Lotus Notes and Domino 8.5Introducing IBM Lotus Notes and Domino 8.5
Introducing IBM Lotus Notes and Domino 8.5Thomas Coustenoble
 
Beer vs wine by Sandip Murari
Beer vs wine by Sandip MurariBeer vs wine by Sandip Murari
Beer vs wine by Sandip MurariSandip Murari
 
Modern Management Thoughts
Modern Management ThoughtsModern Management Thoughts
Modern Management ThoughtsRavi Yasas
 
Proposal: A Study on Business Communucation System of KAZ Software
Proposal: A Study on Business Communucation System of KAZ SoftwareProposal: A Study on Business Communucation System of KAZ Software
Proposal: A Study on Business Communucation System of KAZ SoftwareMinhas Kamal
 
Software Project Management: Release Notes
Software Project Management: Release NotesSoftware Project Management: Release Notes
Software Project Management: Release NotesMinhas Kamal
 
Software Project Management: Configuration Management
Software Project Management: Configuration ManagementSoftware Project Management: Configuration Management
Software Project Management: Configuration ManagementMinhas Kamal
 
Software Requirements Specification on Bengali Braille to Text Translator
Software Requirements Specification on Bengali Braille to Text TranslatorSoftware Requirements Specification on Bengali Braille to Text Translator
Software Requirements Specification on Bengali Braille to Text TranslatorMinhas Kamal
 
Software Project Management: Testing Document
Software Project Management: Testing DocumentSoftware Project Management: Testing Document
Software Project Management: Testing DocumentMinhas Kamal
 
Project Proposal: Bengali Braille to Text Translation
Project Proposal: Bengali Braille to Text TranslationProject Proposal: Bengali Braille to Text Translation
Project Proposal: Bengali Braille to Text TranslationMinhas Kamal
 
A pattern based approach to the development of updm architectures
A pattern based approach to the development of updm architecturesA pattern based approach to the development of updm architectures
A pattern based approach to the development of updm architecturesGraham Bleakley
 
Software Project Management: Project Planning
Software Project Management: Project PlanningSoftware Project Management: Project Planning
Software Project Management: Project PlanningMinhas Kamal
 

Destacado (20)

SRS Document Of Course management software system.doc
SRS Document Of Course management software system.docSRS Document Of Course management software system.doc
SRS Document Of Course management software system.doc
 
Examples of sql queries
Examples of sql queriesExamples of sql queries
Examples of sql queries
 
Lotus Admin Training Part I
Lotus Admin Training Part ILotus Admin Training Part I
Lotus Admin Training Part I
 
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notesHow to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
How to fix ‘database is corrupt: cannot allocate space’ error in lotus notes
 
example of sql injection
example of sql injectionexample of sql injection
example of sql injection
 
Overview of lotus notes/domino 8.5
Overview of lotus notes/domino 8.5Overview of lotus notes/domino 8.5
Overview of lotus notes/domino 8.5
 
Lotus Notes Client Troubleshooting
Lotus Notes Client TroubleshootingLotus Notes Client Troubleshooting
Lotus Notes Client Troubleshooting
 
IBM Lotus Notes Clients - Differences
IBM Lotus Notes Clients - DifferencesIBM Lotus Notes Clients - Differences
IBM Lotus Notes Clients - Differences
 
Introducing IBM Lotus Notes and Domino 8.5
Introducing IBM Lotus Notes and Domino 8.5Introducing IBM Lotus Notes and Domino 8.5
Introducing IBM Lotus Notes and Domino 8.5
 
Android OS
Android OSAndroid OS
Android OS
 
Beer vs wine by Sandip Murari
Beer vs wine by Sandip MurariBeer vs wine by Sandip Murari
Beer vs wine by Sandip Murari
 
Modern Management Thoughts
Modern Management ThoughtsModern Management Thoughts
Modern Management Thoughts
 
Proposal: A Study on Business Communucation System of KAZ Software
Proposal: A Study on Business Communucation System of KAZ SoftwareProposal: A Study on Business Communucation System of KAZ Software
Proposal: A Study on Business Communucation System of KAZ Software
 
Software Project Management: Release Notes
Software Project Management: Release NotesSoftware Project Management: Release Notes
Software Project Management: Release Notes
 
Software Project Management: Configuration Management
Software Project Management: Configuration ManagementSoftware Project Management: Configuration Management
Software Project Management: Configuration Management
 
Software Requirements Specification on Bengali Braille to Text Translator
Software Requirements Specification on Bengali Braille to Text TranslatorSoftware Requirements Specification on Bengali Braille to Text Translator
Software Requirements Specification on Bengali Braille to Text Translator
 
Software Project Management: Testing Document
Software Project Management: Testing DocumentSoftware Project Management: Testing Document
Software Project Management: Testing Document
 
Project Proposal: Bengali Braille to Text Translation
Project Proposal: Bengali Braille to Text TranslationProject Proposal: Bengali Braille to Text Translation
Project Proposal: Bengali Braille to Text Translation
 
A pattern based approach to the development of updm architectures
A pattern based approach to the development of updm architecturesA pattern based approach to the development of updm architectures
A pattern based approach to the development of updm architectures
 
Software Project Management: Project Planning
Software Project Management: Project PlanningSoftware Project Management: Project Planning
Software Project Management: Project Planning
 

Similar a Oracle examples

Subqueries -Oracle DataBase
Subqueries -Oracle DataBaseSubqueries -Oracle DataBase
Subqueries -Oracle DataBaseSalman Memon
 
Lesson02 学会使用WHERE、ORDER BY子句
Lesson02 学会使用WHERE、ORDER BY子句Lesson02 学会使用WHERE、ORDER BY子句
Lesson02 学会使用WHERE、ORDER BY子句renguzi
 
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Achmad Solichin
 
Les02 Restricting and Sorting Data using SQL.ppt
Les02 Restricting and Sorting Data using SQL.pptLes02 Restricting and Sorting Data using SQL.ppt
Les02 Restricting and Sorting Data using SQL.pptDrZeeshanBhatti
 
ADVANCE SQL-"Sub queries"
ADVANCE SQL-"Sub queries"ADVANCE SQL-"Sub queries"
ADVANCE SQL-"Sub queries"Ankit Surti
 
Restricting and Sorting Data - Oracle Data Base
Restricting and Sorting Data - Oracle Data BaseRestricting and Sorting Data - Oracle Data Base
Restricting and Sorting Data - Oracle Data BaseSalman Memon
 
Lesson06 使用子查询
Lesson06 使用子查询Lesson06 使用子查询
Lesson06 使用子查询renguzi
 
Aggregating Data Using Group Functions
Aggregating Data Using Group FunctionsAggregating Data Using Group Functions
Aggregating Data Using Group FunctionsSalman Memon
 
Lesson04 学会使用分组函数
Lesson04 学会使用分组函数Lesson04 学会使用分组函数
Lesson04 学会使用分组函数renguzi
 
Lesson05 从多表中查询数据
Lesson05 从多表中查询数据Lesson05 从多表中查询数据
Lesson05 从多表中查询数据renguzi
 
Oracle SQL - Aggregating Data Les 05.ppt
Oracle SQL - Aggregating Data Les 05.pptOracle SQL - Aggregating Data Les 05.ppt
Oracle SQL - Aggregating Data Les 05.pptDrZeeshanBhatti
 
Les06- Subqueries.ppt
Les06- Subqueries.pptLes06- Subqueries.ppt
Les06- Subqueries.pptgznfrch1
 

Similar a Oracle examples (20)

Les06
Les06Les06
Les06
 
Subqueries -Oracle DataBase
Subqueries -Oracle DataBaseSubqueries -Oracle DataBase
Subqueries -Oracle DataBase
 
Les02.ppt
Les02.pptLes02.ppt
Les02.ppt
 
Lesson02 学会使用WHERE、ORDER BY子句
Lesson02 学会使用WHERE、ORDER BY子句Lesson02 学会使用WHERE、ORDER BY子句
Lesson02 学会使用WHERE、ORDER BY子句
 
Les02
Les02Les02
Les02
 
Les04
Les04Les04
Les04
 
Les02
Les02Les02
Les02
 
Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)Les06 (using subqueries to solve queries)
Les06 (using subqueries to solve queries)
 
Les06
Les06Les06
Les06
 
Les06
Les06Les06
Les06
 
Les02 Restricting and Sorting Data using SQL.ppt
Les02 Restricting and Sorting Data using SQL.pptLes02 Restricting and Sorting Data using SQL.ppt
Les02 Restricting and Sorting Data using SQL.ppt
 
plsql Les07
plsql Les07 plsql Les07
plsql Les07
 
ADVANCE SQL-"Sub queries"
ADVANCE SQL-"Sub queries"ADVANCE SQL-"Sub queries"
ADVANCE SQL-"Sub queries"
 
Restricting and Sorting Data - Oracle Data Base
Restricting and Sorting Data - Oracle Data BaseRestricting and Sorting Data - Oracle Data Base
Restricting and Sorting Data - Oracle Data Base
 
Lesson06 使用子查询
Lesson06 使用子查询Lesson06 使用子查询
Lesson06 使用子查询
 
Aggregating Data Using Group Functions
Aggregating Data Using Group FunctionsAggregating Data Using Group Functions
Aggregating Data Using Group Functions
 
Lesson04 学会使用分组函数
Lesson04 学会使用分组函数Lesson04 学会使用分组函数
Lesson04 学会使用分组函数
 
Lesson05 从多表中查询数据
Lesson05 从多表中查询数据Lesson05 从多表中查询数据
Lesson05 从多表中查询数据
 
Oracle SQL - Aggregating Data Les 05.ppt
Oracle SQL - Aggregating Data Les 05.pptOracle SQL - Aggregating Data Les 05.ppt
Oracle SQL - Aggregating Data Les 05.ppt
 
Les06- Subqueries.ppt
Les06- Subqueries.pptLes06- Subqueries.ppt
Les06- Subqueries.ppt
 

Último

ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYKayeClaireEstoconing
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxnelietumpap1
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxDr.Ibrahim Hassaan
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxHumphrey A Beña
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptxSherlyMaeNeri
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONHumphrey A Beña
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 

Último (20)

ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITYISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
ISYU TUNGKOL SA SEKSWLADIDA (ISSUE ABOUT SEXUALITY
 
Q4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptxQ4 English4 Week3 PPT Melcnmg-based.pptx
Q4 English4 Week3 PPT Melcnmg-based.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Gas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptxGas measurement O2,Co2,& ph) 04/2024.pptx
Gas measurement O2,Co2,& ph) 04/2024.pptx
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptxINTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
INTRODUCTION TO CATHOLIC CHRISTOLOGY.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Judging the Relevance and worth of ideas part 2.pptx
Judging the Relevance  and worth of ideas part 2.pptxJudging the Relevance  and worth of ideas part 2.pptx
Judging the Relevance and worth of ideas part 2.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATIONTHEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
THEORIES OF ORGANIZATION-PUBLIC ADMINISTRATION
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 

Oracle examples

  • 1. 8-1 Copyright © 2004, Oracle. All rights reserved.
  • 2. Using the NVL Function ex1:- To calculate the annual compensation of all employees, you need to multiply the monthly salary by 12 and then add the commission percentage to the result SELECT last_name, salary, NVL(commission_pct, 0), (salary*12) + (salary*12*NVL(commission_pct, 0)) AN_SAL FROM employees; . . 8-2 Copyright © 2004, Oracle. All rights reserved.
  • 3. Using the NVL2 Function SELECT last_name, salary, commission_pct, NVL2(commission_pct,'SAL+COMM', 'SAL') income FROM employees WHERE department_id IN (50, 80); . . 8-3 Copyright © 2004, Oracle. All rights reserved.
  • 4. Executing Single-Row Subqueries ex1:- displays employees whose job ID is the same as that of employee 141 and whose salary is greater than that of employee 143. SELECT last_name, job_id, salary FROM employees WHERE job_id = ST_CLERK (SELECT job_id FROM employees WHERE employee_id = 141) AND salary > 2600 (SELECT salary FROM employees WHERE employee_id = 143); The result in next slide 8-4 Copyright © 2004, Oracle. All rights reserved.
  • 5. 8-5 Copyright © 2004, Oracle. All rights reserved.
  • 6. Executing Single-Row Subqueries ex2:- Find the job with the lowest average salary. SELECT job_id, AVG(salary) FROM employees GROUP BY job_id HAVING AVG(salary)=(SELECT MIN(AVG(salary)) FROM employees GROUP BY job_id); 8-6 Copyright © 2004, Oracle. All rights reserved.
  • 7. Will This Statement Return Rows? SELECT last_name, job_id FROM employees WHERE job_id = (SELECT job_id FROM employees WHERE last_name = 'Haas'); there is no employee named Haas. So the subquery returns no rows The outer query takes the results of the subquery (null) and uses these results in its WHERE clause. The outer query finds no employee with a job ID equal to null, and so returns no rows 8-7 Copyright © 2004, Oracle. All rights reserved.
  • 8. Executing multiple-Row Subqueries ex3:- display the employees whose there salary equal to the min salary of each department. SELECT last_name, salary, department_id FROM employees WHERE salary IN (SELECT MIN(salary) FROM employees GROUP BY department_id); The result in next slide 8-8 Copyright © 2004, Oracle. All rights reserved.
  • 9. 8-9 Copyright © 2004, Oracle. All rights reserved.
  • 10. Executing multiple-Row Subqueries ex4:- displays employees who are not IT programmers and whose salary is less than that of any IT programmer. SELECT employee_id, last_name, job_id, salary FROM employees 9000, 6000, 4800,4200 WHERE salary < ANY (SELECT distinct salary FROM employees WHERE job_id = 'IT_PROG') AND job_id <> 'IT_PROG'; =ANY is equivalent to IN. >ANY means more than the minimum. <ANY means less than the maximum The result in next slide 8-10 Copyright © 2004, Oracle. All rights reserved.
  • 11. . . 8-11 Copyright © 2004, Oracle. All rights reserved.
  • 12. Executing multiple-Row Subqueries ex4:- displays employees who are not IT programmers and whose salary is less than that of all IT programmer. SELECT employee_id, last_name, job_id, salary FROM employees 9000, 6000, 4800,4200 WHERE salary < ALL (SELECT distinct salary FROM employees WHERE job_id = 'IT_PROG') AND job_id <> 'IT_PROG'; >ALL means more than the maximum <ALL means less than the minimum The result in next slide 8-12 Copyright © 2004, Oracle. All rights reserved.
  • 13. . . . . 8-13 Copyright © 2004, Oracle. All rights reserved.
  • 14. Create a query that displays the first eight characters of the employees’ last names and indicates the amounts of their salaries with stars. Each star signifies a thousand dollars. Sort the data in descending order of salary. Label the column EMPLOYEES_AND_THEIR_SALARIES. 8-14 Copyright © 2004, Oracle. All rights reserved.
  • 15. 8-15 Copyright © 2004, Oracle. All rights reserved.
  • 16. 8-16 Copyright © 2004, Oracle. All rights reserved.
  • 17. 8-17 Copyright © 2004, Oracle. All rights reserved.
  • 18. The function check_sal is written to check if the salary of a particular employee is greater or less than the average salary of all employees working in his department. The function returns TRUE if the salary of the employee is greater than the average salary of employees in his department else returns FALSE. The function returns NULL if a NO_DATA_FOUND exception is thrown. 8-18 Copyright © 2004, Oracle. All rights reserved.
  • 19. 8-19 Copyright © 2004, Oracle. All rights reserved.
  • 20. Observe that the function checks for the employee with the employee ID 205. The function is hard coded to check for this employee ID only. If you want to check for any other employees, you will have to modify the function itself. You can solve this problem by declaring the function such that it accepts an argument. You can then pass the employee ID as parameter. 8-20 Copyright © 2004, Oracle. All rights reserved.
  • 21. 8-21 Copyright © 2004, Oracle. All rights reserved.
  • 22. 8-22 Copyright © 2004, Oracle. All rights reserved.
  • 23. 8-23 Copyright © 2004, Oracle. All rights reserved.
  • 24. 8-24 Copyright © 2004, Oracle. All rights reserved.

Notas del editor

  1. … …
  2. … …