Use the table given below and write queries for the below situations EMPLOYEE(EmpId, EmpName, Salary, Gender, Department, JoiningDate) (a) List the details of the employee whose name starts with alphabet D. (b) List the details of the employee whose salary is between Rs. 1000 and Rs. 3000. (c) List the details of all the male employees. (d) List the details of the employees who are in marketing department. (e) Find the Average salary distributed in the company. (f) List the details of the employee whose salary is greater than Rs. 5000 (g) List the details of the employee whose joining date is before 01/01/2012. (h) List the details of the employee who belongs to either marketing or finance department. (i) List the details of the employee who are not working in the purchase department. (j) List the details of the employee who have joined after 10/09/2011 and working in finance department.
Answers
Answer:
a) select * from employee where empname like 'd%'
b) select * from employee where salary between 3000 and 5000
c)select * from employee where gender='male'
d)select * from employee where department='marketing'
e)select avg(salary) from employee
f)select * from employee where salary > 5000
g) select* from employee where joiningdate <'01/01/2012'
h) select* from employee where department in ('marketing', 'finance')
I) select* from employee where department <> 'purchase'
j) select * from employee where joiningdate > '10/09/2011' and department='finance'
(a) Select * from Employee where EmpName like 'D%';
(b) Select * from Employee where Salary between 1000 and 3000;
(c) Select * from Employee where Gender = 'M';
(d) Select * from Employee where Department = 'Marketing';
(e) Select sum(Salary)/2 as 'Average Salary' from Employee;
(f) Select * from Employee where Salary > 5000;
(g) Select * from Employee where JoiningDate < '2012-01-01';
(h) Select * from Employee where Department = 'Marketing' or Department = 'Finance';
(i) Select * from Employee where Department != 'Purchase';
(j) Select * from Employee where JoiningDate > '2011-09-01' and Department = 'Finance';