Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Tarala Leizel L8 MultipleRow-LabExer008

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Course Code Type Course Code Here

Database Management System


Description
1
College / Department:
LabExerNo. 008
Online Education
Laboratory Exercise Page 1 of 1
Direction:
 Use the EMPLOYEES table to perform this activity.
 In each sample output per number, write the PL/SQL that will
generate output per number as shown below.
1. NAME MAX(SALARY)
--------------------- -----------
ZLOTKEY,ELENI 24000

CODE: SQL> SELECT LASTNAME || ',' || FIRSTNAME,MAX(SALARY)


FROM EMPLOYEES
WHERE LASTNAME LIKE 'Z%'
GROUP BY LASTNAME,FIRSTNAME,SALARY;

2. COMPLETE NAME LOWEST MANAGER_ID


--------------------------------- -----------------
Alexander Surnname Is Hunold 100

CODE: SELECT
MIN(initcap(FIRSTNAME||" surnname is "||LASTNAME)) AS”COMPLETE NAME”,
MIN(MANAGER_ID) AS “LOWEST MANAGER_ID”
FROM EMPLOYEES;

3. COUNT(*)
----------
20
CODE: SQL> SELECT COUNT(LASTNAME)AS "COUNT(*)"
2 FROM EMPLOYEES;

4. NO. OF MANAGER_ID
-----------------
19

CODE: SQL> SELECT COUNT(MANAGER_ID)AS "NO. OF MANAGER_ID"


2 FROM EMPLOYEES;

5. NO. OF MANAGER_ID
-----------------
8

CODE: SQL> SELECT COUNT(MANAGER_ID)AS "NO. OF MANAGER_ID"


2 FROM EMPLOYEES
3 WHERE JOB_ID IN('ST_CLERK', 'SA_REP', 'MK_REP');

6. JOB_ID NO. OF JOB_ID SUM(SALARY) AVG(SALARY)


---------- ------------- ----------- -----------
IT_PROG 3 10200 5100
AC_MGR 1 12000 12000
AC_ACCOUNT 1 8300 8300
ST_MAN 1 5800 5800
AD_ASST 1 4400 4400
AD_VP 2 34000 17000
SA_MAN 1 10500 10500
MK_MAN 1 13000 13000
AD_PRES 1 24000 24000
SA_REP 3 26600 8866.66667
MK_REP 1 6000 6000
ST_CLERK 4 11700 2925

12 Rows selected.

CODE: SQL> SELECT JOB_ID, COUNT(JOB_ID) AS "NO. OF JOB_ID",


SUM(SALARY), AVG(SALARY)
2 FROM EMPLOYEES
3 GROUP BY JOB_ID;

7. MIN(LASTNA JOB_ID MAX(SALARY)


---------- ---------- -----------
ABEL SA_REP 11000
FAY MK_REP 6000

CODE: SQL> SELECT MIN(LASTNAME) AS "MIN (LASTNA", JOB_ID,


MAX(SALARY)
2 FROM EMPLOYEES
3 WHERE EMPLOYEE_ID IN(174, 202)
4 GROUP BY JOB_ID;

8. MAX(FIRSTN MANAGER_ID COUNT(SALARY) AVG(SALARY)


---------- ---------- ------------- -----------
KIMBERLEY 149 2 7800
WILLIAM 205 1 8300
BRUCE 102 1 6000
PAT 201 1 6000

CODE: SQL> SELECT MAX(FIRSTNAME), MANAGER_ID, COUNT(SALARY),


AVG(SALARY)
2 FROM EMPLOYEES
3 WHERE MANAGER_ID IN(149,205,102,201)
4 GROUP BY MANAGER_ID;

9. NAME DEPARTMENT_ID
-------------------- -------------
DE HAANLEX 90
ABELELLEN 50

CODE: SELECT CONCAT(LASTNAME,FIRSTNAME)AS "NAME", DEPARTMENT_ID


FROM EMPLOYEES
WHERE EMPLOYEE_ID IN (102, 174)

10. MIN(LASTNA MAX(FIRSTN SUM(SALARY) AVG(SALARY)


---------- ---------- ----------- -----------
DAVIES TRINA 17500 3500

CODE: SQL> SELECT MIN(LASTNAME) AS "MIN (LASTNA", MAX(FIRSTNAME)


AS "MAX (FIRSTN", SUM(SALARY), AVG(SALARY)
2 FROM EMPLOYEES
3 WHERE SALARY BETWEEN 3100 AND 3500
4 GROUP BY SALARY;

You might also like