Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Express each of the following queries in SQL against the relational schema defined above. Each query should be expressed using a single SQL statement. For
Express each of the following queries in SQL against the relational schema defined above. Each query should be expressed using a single SQL statement.
- For each customer who has done at least one purchase transaction, list his/her member id, name and contact information. There should not be duplicates in the result.
- For each purchase transaction done in January 1st, 2020 or later, list its transaction time, name of the member who made the purchase and the name of each product purchased in the transaction.
- List the name and contact information of each member who has purchased at least one product but has never returned any purchased product.
- For each (purchase or return) transaction assisted by the employee with the employee id 'K00236', list the transaction's (purchase or return respectively) store name and the (purchase or return) time.
- List the barcode, the name and the price of each product that has been purchased by EVERY customer at least once.
- For each customer, list his/her name, contact information, and the total number of purchase transactions done by him/her during January 1st, 2019 and December 31, 2019 (inclusive). If the customer didn't make any purchase in that period, still show his/her name and contact information, and list 0 as the total number purchase transactions.
- For each purchase transaction, list the name of the customer who made the purchase, the transaction time, the number of product items purchased in this transaction and the total amount involved in this purchase. The total amount is calculated as the sum of the price of each product purchased in this transaction.
- List the name and contact information of each customer who has done more than 10 purchase transactions. Order the results according to the number of purchase transactions done by the customer in descending order.
- List the name, description and price of the most expensive product.
- List the address and phone number of the store which has the most number of members. That is, the most number of customers chose this store to open his/her membership account.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started