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

You might also like

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

Kishinchand Chellaram College, Mumbai 20

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

1.Find all customers who live in same city as their sales person SELECT cName,sName,c.city FROM customers AS c,salesPeople AS s WHERE c.city=s.city

2.Find the name of all customers match with the sales people SELECT cName,sName FROM customers,salesPeople WHERE cName=sName

3.Display each order # followed by the name of the customer who makes the order SELECT cName,oNum FROM customers,orders WHERE orders.cNum=customers.cNum

4.List all customers serviced by sales person with commission above 10% . Output the customer name, salesperson name SELECT cName,sName FROM customers,salesPeople WHERE customers.sNum = salesPeople.sNum AND commission>0.1

5.Find the name of all customers and salespeople with the salespeople name less than customers name and customers rating below 100 SELECT cName,sName FROM customers,salesPeople WHERE cName>sName AND rating<100

6.Find all orders by customers not located in the same city as their salesperson SELECT oNum,cName FROM customers AS c,orders AS o,salesPeople AS s WHERE c.city<>s.city AND c.cNum=o.cNum AND s.sNum=o.sNum

7.Write a query that display the name of both the customer and the salesperson for each order after the order # SELECT oNum,cName,sName FROM customers AS c,salesPeople AS s, orders AS o WHERE c.cNum=o.cNum AND s.sNum=o.sNum

Kishinchand Chellaram College, Mumbai 20


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

8.Calculate the amount of salespersons commission on each order by a customer with a rating above 100 SELECT commission*amount/100,oNum,sName FROM orders AS o,salesPeople AS s, customers AS c WHERE rating <100 AND o.cNum=c.cNum AND o.sNum=s.sNum

9.Find all the pair of customers having the same ratings SELECT c1.cName,c2.cName FROM customers AS c1,customers AS c2 WHERE c1.rating=c2.rating AND c1.cNum<>c2.cNum

10.Find the pair of customers serviced by single salesperson SELECT c1.cName,c2.cName FROM customers AS c1,customers AS c2 WHERE c1.sNum=c2.sNum AND c1.cNum<>c2.cNum

11.Display the pair of salespersons who are living in the same city. Exclude the combination of salespeople with themselves as well as duplicates SELECT s1.sName,s2.sName FROM salesPeople AS s1,salesPeople AS s2 WHERE s1.city=s2.city AND s1.sNum<>s2.sNum

12.Display all pairs of orders given by customer. Name that customer and also eliminate the duplicates SELECT o1.oNum,o2.oNum,cName FROM orders AS o1,orders AS o2,customers AS c WHERE o1.cNum=o2.cNum AND o1.oNum<>o2.oNum AND o1.cNum=c.cNum

13.Display the name and the city of all customers with the same rating as Fernie SELECT c1.cName,c1.city FROM customers AS c1,customers AS c2 WHERE c1.rating=c2.rating AND c2.cName='Fernie'

Kishinchand Chellaram College, Mumbai 20


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

14.Create Department table with columns d_no as PK and d_name , Location CREATE TABLE department( d_no VARCHAR(3) PRIMARY KEY, d_name VARCHAR(30), location VARCHAR(30) ) 15.Create table Employees with columns e_no as PK, e_name, doj, salary, d_no as FK CREATE TABLE employees ( e_no VARCHAR(3) PRIMARY KEY, e_name VARCHAR(30), doj DATETIME, salary MONEY, d_no VARCHAR(3) FOREIGN KEY REFERENCES department(d_no) ) 16.Display e_no,d_no,e_name,d_name from employee and department tables. Also display the records of the emoployee table which are not having the matching records in the department table. SELECT e_no,d.d_no,e_name,d_name FROM employees AS e,department AS d WHERE e.d_no *= d.d_no

17.Display d_name and location from employee and department and also display additional records of the department table which are having no matching records in the employee table SELECT e_no,d_name,location FROM department AS d FULL OUTER JOIN employees AS e ON e.d_no=d.d_no

You might also like