Sie sind auf Seite 1von 5
Practice 2 MATRIZ SA. ‘The HR department needs your assistance in creating some queries 1. Because of budget issues, the HR department needs a report that displays the last name and salary of employees who earn more than $12,000. Save your SQL statement as a file named lab_02_01. sql. Run your query. ° @ uast_vave |) Salary 2 1 king 24000 zeta food = en a aan Ty 4 Tayler @ Last_wane 2 cePartwenT_ 80 Unauthorized reproduction or distribution prohibited, Copyright© 2013, Oracle and/or its affil @ cast_newe |i) sacany + ing 74000 2 Kochhar 417000 3 De Haan 47000 4 Lorentz 4200 3 Raje 3800 jose, Ose 3100 7 Mees a0 8 Verges a0 8 Whalen 400 4101 Haristein 13000 2. Open a new SQL Worksheet. Create a report that displays the last name and department number for employee number 176. Run the query. aX 3. The HR department needs to find high-salary and low-salary emplgees- Modify lab_02_01. sq] to display the last name and salary for any’ethp the range of $5,000 to $12,000. Save your SQL StargapAl as lab sy employee whose salary is not in 03. sql Oracle Database 11g: SQL Fundamentals | 2- 40 MATRIZ SA. Practice 2 (continued) 4, Create a report to display the last name, job ID, and hire date for employees with the last names of Matos and Taylor. Order the query in ascending order by the hire date. @ vast_wame |i] Joe |HIRE_DATE 1 Matos ST_CLERK 15-MAR-98 2 Taylor SA_REP — 24-MAR-98 tes. 5. Display the last name and department ID of all employees in departments 20 or 50 in ascending alphabetical order by name. W_LasT_Nawe|[)_DePARTWeNT_O Davies Fay Hartstein @ Matos 2 sania a com M5 Rajs ot Wargas aor Neue 6. Modify | ab_02_03. sql to display the last name and’ ee, of eiployees who earn between $5,000 and $12,000, and are in department 20 ey ‘Label (be columns Employee and Monthly Salary, respectively. Resav: Q3\'Sq1 as lab_02_06. sq. Run the statement in lab_02_06. sql 1 Fay 2 Mouirgos. 5800 S % 2 ©. 2 Unauthorized reproduction or distribution prohibited, Copyright© 2013, Oracle and/or its affil Oracle Database 11g: SQL Fundamentals | 2-41 tes. Unauthorized reproduction or distribution prohibited, Copyright© 2013, Oracle and/or its affil Practice 2 (continued) MATRIZ SA. 7. The HR department needs a report that displays the last name and hire date for all employees who were hired in 1994. Last Mame |HIRE_DATE 1 Higgins OF -JUIN-S 2 Gietz O7-JUN-94 8. Create a report to display the last name and job title of all employees who do not have a ‘manager. @ Last_NaMe @ vob ID 1 King AD_PRES 9. Create a report to display the last name, salary, and commission of all employees who earn commissions. Sort data in descending order of salary and commissions. Use the column's numeric position in the ORDER BY clause. wast Nane @ savany |) _commssion pcr 1 Abel 2 Zlotkey 3 Taylor 4 Grant 11000 10800 8600 7o00 0 02 a2 aas 10. Members of the HR department want to liave more flexibility with the queries that you are writing. They would like a report that displays the last name and salary of employees who earn ‘more than an awiount that the user specifies after a prompt. Save this query to a file named Jab_02\1G. sqJ. Ifyou enter 12000 when prompted, the report displays the following results: @ cast naw @ saan 1 King 2 Kochhar 2 De Haan 4 Hartstein 24000 +7000 47000 43000 Oracle Database 11g: SQL Fundamentals | 2 - 42 MATRIZ SA. Practice 2 (continued) 11. The HR department wants to run reports based on a manager. Create a query that prompts the user for a manager ID and generates the employee ID, last name, salary, and department for that manager's employees. The HR department wants the ability to sort the report on a selected column. You can test the data with the following values: g manager_id = 103, sorted by last_name: 7 B eweroveco |) Lastame |g) savary |g] DEPARTMENT ID ie 1 104 Ernst 5000 50 e 2 407 Lorentz 4200 eo 5 2 id = 201, sorted by sal 5 manager_id = 201, sorted by sala 2 g @ eMPLOvEe_io |] LasT_NAME |i) SALARY |] DEPARTMENT ID a 5 1 202 Fay ‘6000 20 oe o ow) 5 ‘manager_id = 124, sorted by employee_id an? 5 OT g @ emecovecto |g) castwame|& savary |§ department io 2 4 4141 Rais 3500 so = 2 142 Davies 00 50 2 5 143 Matos 2600 50 3 4 148 Vargas 2500 50 5 CUT e~ 8 Ace” a et se 3 vO fe 5 7 a ioe” ayo" Bose go 3)O 6 s S 3S S 3 ee a 2 3 3 N Ss = g 5 Oracle Database 11g: SQL Fundamentals | 2 - 43 MATRIZ SA. Practice 2 (continued) If you have time, complete the following exercises: 12, Display all employee last names in which the third letter of the name is * @ Last_name 1 Grant 2 Whalen tes. 13. Display the last names of all employees who have both an “a” and an “e” in their last name. Last_Nane 1 Davies 2 DeHeen 3 Hartstein 4 Whalen If you want an extra challenge, complete the following exercises: 14, Display the last name, job, and salary for all employees whose jobs are either those of a sales representative or of a stock clerk, and whose salaries are not equal to $2,500, $3,500, or $7,000. OD castnawe|@) sop 0/8 savany 1 abel sare 11000 2 Taylor SA_ReP e600 3 Davies: ST_CLERK 3100 4 Matos: ‘ST_CLERK 2600 15. Modify tab_02_06 sq! to display the last name, salary, and commission for all employees whose commission is 20%. Resave 1ab_02_06.sqi as lab_02_15. sql. Rerun the statement in |ab_02_15.sq1 B_empoyec |] Monthy Sotery |B) _conmassion pcr 4 Zotkey ‘0800 02 2 Taylor 3600 O2 Unauthorized reproduction or distribution prohibited, Copyright© 2013, Oracle and/or its affil Oracle Database 11g: SQL Fundamentals | 2-44

Das könnte Ihnen auch gefallen