0% found this document useful (0 votes)
66 views2 pages

DDSQL s7 Exs - 2

The document outlines 14 queries to run across 4 tables (Products, OrderDetails, Orders, Customers) to analyze customer preferences, popular products, total purchases by customer, and orders by employee. It asks to list products in each category, customers' purchased products sorted by customer, most popular products purchased by most customers, each product's extension price on each order, total amount owed on each order, total purchased by each customer, specific customer orders, orders for customers from Berlin, lowest priced product details, orders with customer names using joins, repeating the previous join using a different syntax, and joining 3 tables to show product, supplier and category details. It also asks for orders in Germany by a specific employee and total orders by

Uploaded by

Huynh Vinh Tai
Copyright
© Attribution Non-Commercial (BY-NC)
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)
66 views2 pages

DDSQL s7 Exs - 2

The document outlines 14 queries to run across 4 tables (Products, OrderDetails, Orders, Customers) to analyze customer preferences, popular products, total purchases by customer, and orders by employee. It asks to list products in each category, customers' purchased products sorted by customer, most popular products purchased by most customers, each product's extension price on each order, total amount owed on each order, total purchased by each customer, specific customer orders, orders for customers from Berlin, lowest priced product details, orders with customer names using joins, repeating the previous join using a different syntax, and joining 3 tables to show product, supplier and category details. It also asks for orders in Germany by a specific employee and total orders by

Uploaded by

Huynh Vinh Tai
Copyright
© Attribution Non-Commercial (BY-NC)
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/ 2

From two tables: Products and Categories.

1. What products exist in each category? 2. Same question, but alphabetize the list by category and product. 3. How many products are there in each category? 4. What is the average price in each category? (sort from highest to lowest)

From four tables: Products, OrderDetails, Orders and Customers.


1. (Customer preferences) List all of the products each customer has ever ordered sorted by customer and product. 2. (High-variety-to-low-variety customers) How many different kinds of products each customer has ordered sorted high to low. 3. (Most-widely-popular-to-least-widely-popular products) What products have been purchased by the most customers? (List in descending order) 4. (Invoice) What is the extension (price x quantity) of each product on each order for each customer? (A calculated field is needed here. Also include the order date.) 5. (Amount due) What is/was the total amount owed on each order? 6. (Best customers) What is the total amount purchased by each customer? (List in descending order.) 7. In the sub-query find the customerID for the customer with the company name 'Alfreds Futterkiste'. Use that customerID to find orderID and orderDate for this customer's orders. 8. In the sub-query find the customerIDs of the customers with city = 'Berlin'. Use these customerIDs to find orderID and orderDate for these customer's orders. 9. In the sub-query find the minimum unitPrice from the table products. Use this price to find productID and productName for the product(s) which has the minimal price. 10. Join the tables customers and orders (comparing the attribute customerID), and show the attributes orderID, orderDate, and customerName. Use the syntax from page 59.

11. Repeat the above question using the 1st of the 3 join syntaxes on page 60 (the 2 other join syntaxes are not legal in Microsoft SQL Server) 12. Join the 3 tables products, suppliers, and categories - and show the attributes productID, productName, companyName, and categoryName 13. Which were the order numbers for those orders by customers in Germany that were taken by the employee named "Suyama?" 14. What is the total number of orders taken by each employee.

You might also like