0% found this document useful (0 votes)
4 views

Lab Assignment-7

The document outlines an assignment involving SQL subqueries with three tables: SalesPeople, Customers, and Orders, detailing their structures and relationships. It includes tasks such as creating the tables, inserting records, and executing various queries to extract specific data about salespeople and customers based on different criteria. The assignment emphasizes the use of SQL to manipulate and retrieve data effectively from the provided tables.

Uploaded by

ygoyal2be23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Lab Assignment-7

The document outlines an assignment involving SQL subqueries with three tables: SalesPeople, Customers, and Orders, detailing their structures and relationships. It includes tasks such as creating the tables, inserting records, and executing various queries to extract specific data about salespeople and customers based on different criteria. The assignment emphasizes the use of SQL to manipulate and retrieve data effectively from the provided tables.

Uploaded by

ygoyal2be23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 7

(Subquery in SQL)
Table 1: SalesPeople
Snum is Primary key
Sname is Unique constraint
Snum Sname City Comm

1001 Peel London 0.12

1002 Serres Sanjose 0.13

1004 Motika London 0.11

1007 Rifkin Barcelona 0.15


1003 Axelrod New York 0.10

Table 2: Customers
Cnum is Primary Key
City has not null constraint.
Snum is foreign key constraint refers Snum column of SalesPeople table.
Cnum Cname City Snum

2001 Hoffman London 1001

2002 Giovanni Rome 1003

2003 Liu Sanjose 1002

2004 Grass Berlin 1002

2006 Clemens London 1001

2008 Cisneros Sanjose 1007


2007 Pereira Rome 1004
Table 3: Orders
Onum is Primary key
Cnum is foreign key refers to Cnum column of Customers table.
Snum is foreign key refers Snum column of SalesPeople table.
Onum Amt Odate Cnum Snum

3001 18.69 3-10-1990 2008 1007

3003 767.19 3-10-1990 2001 1001

3002 1900.10 3-10-1990 2007 1004

3005 5160.45 3-10-1990 2003 1002

3006 1098.16 3-10-1990 2008 1007

3009 1713.23 4-10-1990 2002 1003

3007 75.75 4-10-1990 2004 1002

3008 4273.00 5-10-1990 2006 1001

3010 1309.95 6-10-1990 2004 1002


3011 9891.88 6-10-1990 2006 1001
1) Create the above three tables and insert those records.
2) Display all the salesperson whose all orders worth is more than Rs. 2000.
3) Display the salesperson id handling at least two customers.
4) Display the salesperson names handling at least two customers.
5) Display the number of Salespeople belonging to London and Paris.
6) Display the customer names corresponding to salesperson belonging to
London and Paris.
7) Display the customer names whose order amount is worth 1200.
8) Display the customer names who belong to the same city as their
salesperson.
9) Display the salesperson names having commission more than 10 percent
and who handled more than two customers.
10) Display the customer’s name who orders exactly one order and his
salesperson name.
11) Insert the details of a salesperson in the table who is a new joined
and did not handle any customer. Write a query for the salesperson
who has not handle any customer.
12) Write a query that counts the number of Salespeople registering orders
for each day.
13) Find out the no. of Salesperson who belongs to same city and have same
commission percentage.

You might also like