Queriesusingaggregatefunctions (COUNT, AVG, MIN, MAX, SU M), Group By, Orderby, Having. E - Id E - Name Age Salary
Queriesusingaggregatefunctions (COUNT, AVG, MIN, MAX, SU M), Group By, Orderby, Having. E - Id E - Name Age Salary
M),Group by,Orderby,Having.
EID --
NUMBER
ENAME VARCHAR2(10
AGE )
NUMBER
SALARY NUMBER
7
(iii) Find the Maximum age from employeetable.
SQL> select max(age) from emp;
MAX(AGE)
44
(iv) Find the Minimum age from employeetable.
SQL> select min(age)
from emp;
MIN(AGE)
22
Display the Sum of age employeetable.
SQL> select sum(age) from emp;
SUM(AGE)
220
Display the Average of age from Employeetable.
SQL> select avg(age) from emp; AVG(AGE)
31.4285714
Create a View for age in employeetable.
SQL> create or replace view A as select age from emp where age<30; View created.
Displayviews
SQL> select * from A;
AGE
22
29
27
29
(v) Find grouped salaries of employees.(group byclause)
SQL> select salary from emp group
by salary; SALARY
9000
10000
8000
6000
7000
(x).Find salaries of employee in Ascending Order.(order by clause)
SQL> select ename,salary from
emp order by salary;
ENAME SALARY
rohan 6000
alex 7000
shane 8000
abhi 8000
tiger 8000
anu 9000
scott 10000
7 rowsselected.
(xi) Find salaries of employee in DescendingOrder.SQL> select ename,salary from
emp order by salary desc;
ENAME SALARY
scott 10000
anu 9000
Shane 8000
Abhi 8000
Tiger 8000
Alex 7000
Rohan 6000
7 rows selected.
(xii) HavingClause.
SQL> select ename,salary from emp where age<29 group by ename,salary
having salary<10000;
ENAME SALARY
alex 7000
anu 9000