You are on page 1of 2

Tasks 9

1.Max
----Query 1: retrieve max salary from Teacher.
select Max(salary) as[Maximum sallary] from teacher
--Query 2: retrieve max Bonus from teacher where t_fname starts with S.
select Max(bonus) as[Maximum Bonus] from teacher where t_fname like 's%'
----Query 3: retrieve max yearsofexp from Teachers where age is in 30 and
35.year
select Max(yearofexp) as[Maximum yearofexp] from teacher where age in(30,35)
---Query 4: retrieve max house allowance from teacher where qualification is MS
select Max(houseallowence) as[Maximum houseallowence] from teacher where
qualification='Ms'
---Query 5: retrieve max salary where age is greater than 25 and less than 30.
select Max(salary) as[Maximum salary] from teacher where age>25 AND age<30

2.MIN
---Query 1: retrieve min salary from Teacher.
select Min(salary) as[Minimum sallary] from teacher
--Query 2: retrieve min Bonus from teacher where t_fname starts with S.
select Min(bonus) as[Minimum Bonus] from teacher where t_fname like 's%'
--Query 3: retrieve min yearsofexp from Teachers where age is in 30 and 35.
select Min(yearofexp) as[Minimum yearofexp] from teacher where age in(30,35)
--Query 4: retrieve min house allowance from teacher where qualification is MS
select Min(houseallowence) as[Minimum houseallowence] from teacher where
qualification='Ms'
--Query 5: retrieve min salary where age is greater than 25 and less than 30.
select Min(salary) as[Minimum salary] from teacher where age>25 AND age<30

3.Count
--Query 1: retrieve total number of distinct yearsofexp from teacher.
select count(distinct yearofexp) as[Total yearsofexp] from teacher
--Query 2: retrieve total number of salaries whose qualification is MS.
select count(salary) as [Total sallaries] from teacher where qualification='Ms'
--Query 3: retrieve total number of distinct t_name from teacher.
select count(distinct t_fname+' '+t_lname) as [Total Teachers distinct name]
from teacher
--Query 4: retrieve total number of salaries from teacher where age is greater
than 28.
select count(salary) as[Total sallaries] from teacher where age>28
--Query 5: retrieve total number of distinct qualifications from teacher
select count(distinct qualification) as[Total distinct qualifications] from
teacher
4.Sum

--Query 1: show total salary from teachers.


select sum(salary) as [Total sallaries] from teacher
--Query 2: retrieve total years of experience from teachers.
select sum(yearofexp) as [Total yearsofexp] from teacher
-- Query 3: retrieve total Bonus from Teacher where tid is 5001 and 5007.
select sum(bonus) as [Total bonus] from teacher where tid='5001' Or tid='5007'
--Query 4: retrieve total House Allowance where age is greater than 30.
select sum(houseallowence) as [Total houseallowence] from teacher where age>30
--Query 5: retrieve sum of all bonus where t_lname is Ahmad
select sum(bonus) as [Total bonus] from teacher where t_lname='Ahmad'

5.Bonus
--Query 1: show Average salary from teachers.
select Avg (salary) as[Avg sallary] from teacher
--Query 2: retrieve Average years of experience from teachers.
select Avg (yearofexp) as[Avg yearsofexp] from teacher
--Query 3: retrieve Average Bonus from Teacher where tid is 5001 and 5007.
select Avg (bonus) as[Avg bonus] from teacher where tid=5001 or tid=5007
--Query 4: retrieve Average House Allowance where age is greater than 30.
select Avg (houseallowence) as[Avg houseallowence] from teacher where age>30
--Query 5: retrieve Average of all bonus where t_lname is Ahmad
select Avg (bonus) as[Avg bonus] from teacher where t_lname='Ahmad'

Exercise9

You might also like