A practical approach towards learning SQL in Oracle 11g. Video lectures are prepared as well and can be found at given link
https://www.youtube.com/channel/UCMv6HrS_4_GFWmLLFzL_U_A?view_as=subscriber
SQL Database Design For Developers at php[tek] 2024
SQL Functions - Oracle SQL Fundamentals
1. SQL Fundamentals Oracle 11g
M U H A M M A D WA H E E D
O R AC L E DATA BA S E D E V E LO P E R
E M A I L : m .wa h e e d 3 6 6 8 @ g m a i l . co m
Lecture#6
SQL Functions(cont’d)
2. Group Functions
There are following types of group functions
•AVG
•COUNT
•MAX
•MIN
•STDDEV
•SUM
•VARIANCE
2
6. Grouping Data(cont’d)
6
Use of GROUP By clause
•All columns specified in SELECT must be in GROUP BY clause
except those in group function.
•Example:
SELECT dept_id , AVG(salary)
FROM employee
GROUP BY dept_id;
7. Grouping Data(cont’d)
7
Use of GROUP BY clause
•All columns specified in GROUP BY may not be in SELECT
clause.
•Example:
SELECT AVG(salary)
FROM employee
GROUP BY dept_id;
9. Grouping Data(cont’d)
9
Use of GROUP BY clause on multiple columns
•Example:
SELECT tch_designation,tch_id,AVG(salary)
FROM employee
GROUP BY dept_id, tch_designation;
12. Grouping Data(cont’d)
12
Use of HAVING clause with group functions
•Example:
SELECT dept_id, MAX(salary)
FROM employee
GROUP BY dept_id
HAVING MAX(salary) >15000;
13. Grouping Data(cont’d)
13
Use of multiple clauses with group functions
•Example:
SELECT dept_id, SUM(salary) AS PAYROLL
FROM employee
WHERE tch_designation NOT LIKE ‘%ASSIST%’
GROUP BY tch_designation
HAVING SUM(salary) >15000
ORDER BY SUM(salary);