You are on page 1of 5

NAME = SANJAY KUMAR

BATCH = A(3,4)
ID = 2016UCP1382

ASSIGEMENT - 2

Create table query along with the foreign key reference:-


The coloums of the tables saleman , customer and orders are : -

The tables are:-


Q1 . Write a SQL statement to prepare a list with salesman name, customer name
and their cities for the salesmen and customer who belongs to the same city.
Ans.:-
select salesman.name , customer.name , customer.city from salesman, customer where
salesman.city = customer.city;

Q2 . Write a SQL statement to find the list of customers who appointed a salesman
for their jobs who does not live in the same city where their customer lives?
Ans.:-
select customer.name , customer.city from salesman, customer where customer.sale_id =
salesman.id and salesman.city != customer.city;
Q3 . Write a SQL statement to know which salesman are working for which
customer?
Ans.:-
select salesman.name , customer.name from salesman, customer where salesman.id =
customer.sale_id;

Q4 . Write a SQL statement to make a list with order no, purchase amount,
customer name and their cities for those orders which order amount between 500
and 2000.
Ans.:- select orders.no , orders.amt, customer.name , customer.city from orders , customer
where orders.cust_id = customer.srno and amt between 500 and 2000;
Q5 . Write a SQL statement to find the list of customers who appointed a salesman
for their jobs who gets a commission from the company is more than 12%.
Ans.:-
select customer.* from customer , salesman where sale_id = id and commission_percent > 12;

Q6 . Write a SQL statement to find the details of a order i.e. order number, order
date, amount of order, which customer gives the order and which salesman works
for that customer and how much commission he gets for an order.
Ans.:-
select orders.no , orders.amt, orders.date, customer.name ,salesman.name ,
salesman.commision from orders , customer,salesman where orders.cust_id = customer.srno
and customer.sale_id = salesman.id order by orders.no;

You might also like