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

Quiz

The document outlines the structure of a database with tables for Customers, Products, Orders, OrderDetails, Categories, and Suppliers, detailing their columns, data types, and descriptions. It also includes various SQL query examples for retrieving and manipulating data, such as SELECT, JOIN, and DELETE queries. The queries cover tasks like filtering customers by city, sorting products by price, and calculating total revenue.

Uploaded by

uzairnoon277
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Quiz

The document outlines the structure of a database with tables for Customers, Products, Orders, OrderDetails, Categories, and Suppliers, detailing their columns, data types, and descriptions. It also includes various SQL query examples for retrieving and manipulating data, such as SELECT, JOIN, and DELETE queries. The queries cover tasks like filtering customers by city, sorting products by price, and calculating total revenue.

Uploaded by

uzairnoon277
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1.

Customers

Column
Data Type Description
Name

INT (Primary Unique ID for each


customer_id
Key) customer

customer_na
VARCHAR(100) Full name of the customer
me

Email address of the


Email VARCHAR(100)
customer

City VARCHAR(50) Customer's city

Phone VARCHAR(20) Contact number

2. Products

Column
Data Type Description
Name

INT (Primary Unique ID for each


product_id
Key) product

product_nam
VARCHAR(100) Name of the product
e

Price DECIMAL(10,2) Price of the product

stock_quantit Quantity available in


INT
y stock

INT (Foreign Linked to Categories


category_id
Key) table

3. Orders

Column
Data Type Description
Name

INT (Primary Unique ID for each


order_id
Key) order

INT (Foreign Linked to Customers


customer_id
Key) table
Column
Data Type Description
Name

order_date DATE Date of the order

4. OrderDetails

Column
Data Type Description
Name

order_detail_i INT (Primary Unique ID for each order


d Key) detail

INT (Foreign
order_id Linked to Orders table
Key)

INT (Foreign
product_id Linked to Products table
Key)

Quantity of the product


quantity INT
ordered

5. Categories

Column
Data Type Description
Name

INT (Primary Unique ID for each


category_id
Key) category

category_na
VARCHAR(50) Name of the category
me

6. Suppliers

Column Data Type Description


Name

supplier_id INT (Primary Unique ID for each


Key) supplier

supplier_na VARCHAR(100) Name of the supplier


me

City VARCHAR(50) City of the supplier

contact_emai VARCHAR(100) Supplier's email


l address

1. Basic SELECT Query


Question: Display the names and email addresses of all customers who
live in "New York."
2. Sorting Query
Question: Retrieve the list of products sorted by price in descending order.
3. Aggregate Function
Question: Find the total number of products available in stock.

4. GROUP BY and HAVING


Question: Calculate the total revenue generated per product, but only display
products with total revenue greater than $500.

5. JOIN Query
Question: List all orders with the customer name, order ID, and order date.
6. Subquery
Question: Find the names of products that are more expensive than the average
product price.

7. Multi-table JOIN
Question: Retrieve the customer name, product name, and quantity for all orders.
8. UNION
Question: Combine and display the list of cities where either customers or
suppliers are located.

9. DELETE Query
Question: Delete all orders placed before January 1, 2023.

You might also like