Assignment#4

You might also like

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

Assignment#4

Given is the table of ‘Teacher’. Do as directed.


Teacher

Tid firstName lastName Dob Gender Qualification salary City


t1 Ali Muhammad 1984-10-15 Male Ph D 85000 RWP
t2 Shahida Jahanzaib 1990-05-03 Female MS 70000 ISB
t4 Faisal Hammad 1988-10-04 Male Ph D 35000 LHR
t5 Ayesha Mukhtar 1991-05-04 Female Ph D 90000 ISB
t6 Nadeem Afzal 1985-06-03 Male MS 95000 LHR
t7 Shahid Abid 1989-07-01 Male MCS 92000 KHI
a) Write down the SQL Queries for following statements.
1) Display details of all Teachers whose qualification is MS or Ph D without using in operator
2) Display full name of all those teachers whose salary is less than equal to 85000 and greater than
equal to 40000 without using relational operators.
3) Display all those teachers who neither lives in rwp nor isb nor khi without using ‘in’ and ‘like’
operator.
4) Display all those teachers whose firstName’s second letter and second last letter is ‘a’.
5) Display first name of all Ph d teachers by adding ‘Mr.’ at start.
6) Display average salary of female teachers using aggregate function.
7) Display count of teachers for each qualification.
8) Display all those teachers whose city is either isb or khi and gender is male without using in op -
erator.
9) Display firstName and lastName of all teachers in such a way that youngest teachers should be
shown on the top.
10) Display of all those teachers whose qualification either ‘MS’ or ‘Ph D’ and last name must end
on vowel letter.
11) Display details of all male teachers who lives in lhr or khi.
12) Display count of all teachers whose salary is greater than 70000 or city is isb.
13) Display details of top 5 teachers who lives in khi.
14) Display all those teachers whose first Name consist of less than 4 characters.
15) Display details of all those teachers whose gender is male and salary is below 50000.
16) Display all those teachers whose first Name consist of exactly 5 characters and at least one ‘a’
at any position.
17) Display all those teachers whose first Name consist of at least 4 characters.
18) Display unique city of teachers whose first Name start either ‘a’ or ‘r’ or ‘m’ or ‘s’ and must
end on vowel letter.
19) Show all those teacher whose salary is 35000 after receiving 10 percent increment in his/her
salary.
20) Show qualification and total number of teacher for each qualification whose total number of
teacher for each city is greater than equal to ‘2’.
b) Consider ‘Teacher’ table given above and draw result for the following SQL queries.
1) Select distinct city from teacher where qualification not in
('BSCS', 'BSIT');
2) Select qualification, count(*) from teacher group by qualifica-
tion;
3) Select firstName, Gender from teacher where salary not between
30000 and 35000;
4) Select top 3 tid ,Salary from teacher where lastName not like
'[Muhammad]%' order by dob asc;
5) Select firstName from teacher where gender = 'male' or salary
between 40000 and 60000
6) Select * from teacher where city=’wrp’ or ‘bsi’;
7) Select firstName, lastName from teacher where age >20 and age>30;
8) Select * from teacher where age<20 or age>30;
9) Select top 3 qualification, salary from teacher where city
in(‘rwp’, ‘isb’,’mulatn’) order by salary asc.
10) Select * from teacher where firstName not like ‘[^aeiou]%’;

You might also like