0% found this document useful (0 votes)
41 views5 pages

Name Sanjay Kumar BATCH A (3,4) ID 2016UCP1382

1) The document contains sample SQL queries and answers related to tables for salesmen, customers, and orders. 2) Six SQL queries are provided to retrieve information on salesmen and customer cities, customers with salesmen in a different city, salesmen assigned to customers, orders between $500-$2000 with customer and city details, and customers with salesmen receiving over 12% commission. 3) The last query returns order number, amount, date, customer, salesman, and salesman commission for each order joined across the tables.

Uploaded by

Sanjay Bhargva
Copyright
© © All Rights Reserved
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)
41 views5 pages

Name Sanjay Kumar BATCH A (3,4) ID 2016UCP1382

1) The document contains sample SQL queries and answers related to tables for salesmen, customers, and orders. 2) Six SQL queries are provided to retrieve information on salesmen and customer cities, customers with salesmen in a different city, salesmen assigned to customers, orders between $500-$2000 with customer and city details, and customers with salesmen receiving over 12% commission. 3) The last query returns order number, amount, date, customer, salesman, and salesman commission for each order joined across the tables.

Uploaded by

Sanjay Bhargva
Copyright
© © All Rights Reserved
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/ 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