0% found this document useful (0 votes)
7 views6 pages

Dellstore Queries en

The document outlines the structure of a database named 'dellstore' which includes tables for categories, customers, inventory, orders, and products. It also lists SQL query requirements for various data retrieval tasks, such as listing product categories, customers, and order statistics. Additionally, it provides instructions for creating and manipulating a 'high_price_products' table based on specific criteria.

Uploaded by

thaiphucdat2007
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)
7 views6 pages

Dellstore Queries en

The document outlines the structure of a database named 'dellstore' which includes tables for categories, customers, inventory, orders, and products. It also lists SQL query requirements for various data retrieval tasks, such as listing product categories, customers, and order statistics. Additionally, it provides instructions for creating and manipulating a 'high_price_products' table based on specific criteria.

Uploaded by

thaiphucdat2007
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/ 6

Database «dellstore»

• Categories(category, categoryname)
• cust_hist(customerid, orderid, prod_id)
• Customers(customerid, firstname, lastname,
address1, address2, city, state, zip, country,
region, email, phone, creditcardtype, creditcard,
creditcardexpiration, username, password, age,
income, gender)
• Inventory(prod_id, quan_in_stock,sales)
• Orderlines(orderlineid, orderid, prod_id,
quantity, orderdate)
• Orders(orderid, orderdate, customerid, netamount,
tax, totalamount)
• Products(prod_id, category, title, actor, price,
special, common_prod_id)
SQL

 SQL commands for the requirements in the next slide.

 These commands are stored in a .sql file. Comments are preceded


by --.

 File name: studentname_mssv.sql

 SQLFile editor:

◼ pgAdmin: SQLEditor
◼ Notepad++
◼ …
Write SQL queries
1. List of product categories
2. List of products in the "Documentary" category
3. List of product categories along with the corresponding number of
products
4. List of products that have never been ordered
5. Where do our customers come from? (List of countries)
6. List of countries along with the number of customers from each
country
7. List of customers who have never placed an order
8. Number of orders by date
9. Number of products purchased on February 3, 2004
10. Display the average order value (i.e., the average total amount per
order)
11. Display a list of the best-selling products
12. List of regular customers (based on the number of orders). A regular
customer is someone who has made more than three purchases
from the store.
13. How many customers have credit card that expired in September
2008?
14. Provide detailed information about the products in the order with
Order ID 942, including: orderlineid, prod_id, product title, quantity,
unit price (with currency unit), amount (with currency unit):
Orderlineid Prod_id Title Quantity Unitprice amount
1 7979 Aladin 3 28.99$ 86.99$

15. How many orders have been placed by the customer with ID
19887?
16. Display information (full name, address, email, and phone
number) of customers who have placed at least 4 orders.
17. Display the order date and total amount of the highest-value
order placed by the customer with ID 19887.
18. Show the full name and email of customers who ordered the
product "AFFAIR ALAMO" in the largest quantity.
19. Display statistics on customers who have ordered products. For
each product and each customer gender, show the number of
customers, average age, and average income.
20. Which products have been ordered by male customers with an
income above 65,000? Display the quantity ordered for each
product and sort the results in descending order by quantity
ordered.
21. Create a high_price_products table with the same structure
as the products table
22. Insert into the high_price_products table all products
with a price greater than 21.99
23. In the high_price_products table:
▪ Products in category 1 should be moved to category 2.
▪ Products priced at 29.99 should be marked as "special products."
▪ Increase the price of all products currently priced between 23.00 and
26.99 (inclusive) by 1 unit ($).
▪ Delete products with a price below 23.00.
24. Remove the high_price_products table

You might also like