0% found this document useful (0 votes)
51 views4 pages

Kishinchand Chellaram College, Mumbai - 20: FY / SY / TY B.Sc. (I.T.) Semester

This document contains the solutions to 22 SQL queries on employee and department tables. The queries return information like orders for a specific salesperson, commissions by city, number of orders by a person, total salaries, minimum and maximum salaries, employees by job type, adding salaries and commissions, average salaries by job, employee and department names, employees by department with high commission, employees by department name, employees in a specific department location, employees with the same hire date, employees and departments with more than 2 employees, salaries and jobs totals over a threshold, difference between highest and lowest salaries, employees by name pattern, employees without commission with a raise, employee details and conditional salaries, and jobs held in certain periods across years.

Uploaded by

urvipatil
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views4 pages

Kishinchand Chellaram College, Mumbai - 20: FY / SY / TY B.Sc. (I.T.) Semester

This document contains the solutions to 22 SQL queries on employee and department tables. The queries return information like orders for a specific salesperson, commissions by city, number of orders by a person, total salaries, minimum and maximum salaries, employees by job type, adding salaries and commissions, average salaries by job, employee and department names, employees by department with high commission, employees by department name, employees in a specific department location, employees with the same hire date, employees and departments with more than 2 employees, salaries and jobs totals over a threshold, difference between highest and lowest salaries, employees by name pattern, employees without commission with a raise, employee details and conditional salaries, and jobs held in certain periods across years.

Uploaded by

urvipatil
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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

Kishinchand Chellaram College, Mumbai 20


FY / SY / TY B.Sc.(I.T.) Semester __________

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'

Kishinchand Chellaram College, Mumbai 20


FY / SY / TY B.Sc.(I.T.) Semester __________

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'

Kishinchand Chellaram College, Mumbai 20


FY / SY / TY B.Sc.(I.T.) Semester __________

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'

You might also like