Beruflich Dokumente
Kultur Dokumente
JOB_ID MIN(SALARY)
---------- -----------
sa_rep 7000
mk_rep 6000
ad_pres 24000
ad_vp 17000
it_prog 4200
st_man 5800
ac_account 8300
sa_man 10500
ad_asst 4400
ac_mgr 12000
st_clerk 2500
mk_man 13000
.
12 rows selected
2. Create a query that counts the number of ST_CLERK job_id. Rename the column as “Total no.
of ST_CLERK”.
Possible Output:
Total no. of ST_CLERK
---------------------
4
SQL> select count(job_id) as "Total no. of ST CLERK" from
employees where job_id='st_clerk';
LOWER(MIN( AVG(SALARY)
---------- -----------
abel 8866.66667
fay 6000
7. Create a query that display the Minimum firstname concatenated to lastname. Look for the
maximum salary per department_id. Note that pad function is applied for the function
maximum.
Possible Output:
Complete Name Maximum Salary DEPARTMENT_ID
--------------------- -------------------------------- -------------
KIMBERLEY GRANT $$$$7000
PAT FAY $$$$6000 20
. SQL> select department_id, max(salary) from employees group by
department_id;
DEPARTMENT_ID MAX(SALARY)
------------- -----------
7000
90 24000
20 13000
110 12000
50 11000
80 10500
60 6000
10 4400
.
7 rows selected
8. Create a query that display the maximum lastname concatenated to firstname and rename the
column as “Employees Name”, Job_id and apply the ff. functions:
Count for the distinct Job_id; Apply where condition whose lastname ends with letter ‘N’;
Group the job_id; and Apply having clause of employees having average salary that is
greater that 10000.
Possible Output
Employees Name JOB_ID COUNT(JOB_ID) JOB_ID
--------------------- ---------- ------------- ----------
De Haan,Lex AD_VP 1 AD_VP
Hartstein,Michael MK_MAN 1 MK_MAN
10. What is the difference between where condition and HAVING clause?
The difference between WHERE clause is used is filter records from a result. The filter occurs
before any groupings are made while HAVING clause is used to filter values from a group.