Kishinchand Chellaram College, Mumbai - 20: FY / SY / TY B.Sc. (I.T.) Semester
Kishinchand Chellaram College, Mumbai - 20: FY / SY / TY B.Sc. (I.T.) Semester
Practical No 5 1)Extract all orders taken by Allen Ans: select onum from orders , salespeople where orders.snum = salespeople.snum and sname = 'Allen'
Date: 22/7/2010
Q2) Find all orders attributed to sales person in London Ans: select onum from orders, salespeople where orders.snum= salespeople.snum and city= 'London'
Q3) Display the commission of all sales persons servicing customers in Canada. Ans: select comm from salespeople, customers where customers.snum = salespeople.snum and customers.city= 'London' Q4) Find the no. of orders placed by John Ans: select count(onum) as No_of_Orders from orders , salespeople where orders.snum = salespeople.snum and sname = 'John'
Q5) Find the total of salaries for all the employees. Ans: select sum(salary) as TotalSalary from employee Q6) Find the total of minimum & maximum salary Ans: select min(salary)+ max (salary) as Total from employee Q7) Find all employees whose job second letter is _a___? Ans: select ename from employee
where job like '_a%' Q8) Add the salary & commission of the employees whose commision is null. Ans: select (salary + comm) as total from employee where comm is null Q9) Find employees average salary whose salary>20000 according to their job & average salary<=30000. Ans: select avg(salary) as AvgSal, job from employee where salary>2000 group by job having avg(salary)<=30
Q10) Find employee name, department name from employee & department table such that employee name< department name. Ans: select ename, d_name from employee, department where ename< d_name
Q11) Display all employees from each department whose commission > 100 Ans: select ename, d_no from employee where comm>100
Q12) Display name of employees from each department. Ans: select ename, d_no from employee
Q13) Find the records from employee table where department is accounts. Ans: select employee.* from employee, department where employee.d_no = department.d_no and d_name like 'accounts'
Q14) Find the employees whose department located in Delhi. Ans: select ename from employee, department where employee.d_no = department.d_no and location like 'Delhi' Q15) Find the employees who have same date of joining. Ans: select distinct(e1.ename) from employee as e1, employee as e2 where e1.emp_no <> e2.emp_no and e1.dateoj = e2.dateoj Q16) Display the details of employees where each department contains more than 2 employees Ans: select emp_no, d_no from employee group by emp_no, d_no having count(d_no)>2 Q17) Display job, total monthly salary for each job with a total salary exceeds 20000. Ans: select job, sum(salary) as total_monthly_Salary from employee group by job,salary having sum(salary)>300 Q18) Display the difference between highest & lowest salary. Ans: select max(salary) - min(salary) as Differece from employee Q19) Display the name of employee starts with A & ends with K Ans: select ename from employee where ename like 'A%K'
Q20) Show all employees that have no commission with 10% raise in salary. select ename, salary +(0.1*salary) as IncreasedSalary from employee where comm is null Q21) Display name , job, salary from employee table. Also print one column based on following conditions (1) If prog then salary * 1.4 (2) If clerk then salary * 1.2 (3) If manager then salary * 1.7 Ans: select ename,job, salary, 1.4 * salary as SalaryHike from employee where job like 'Programmer' Union select ename,job, salary, 1.2 * salary as SalaryHike from employee where job like 'Clerk' Union select ename,job, salary, 1.7 * salary as SalaryHike from employee where job like 'Manager' Q22) Find the job that was filled in the first half of the 1990 & the same job was filled during same period in 1991. Ans: select job from employee where dateoj between '1-25-1990' and '7-25-1990' Union select job from employee where dateoj between '1-25-1991' and '7-25-1991'