Question: Data Type: ProductID: Integer, ProductName: Text, Quantity: Integer, Price: Decimal Data Type: TransactionID: Auto-increment Integer, ProductID: Integer, CustomerID: Integer, TransactionDate: Date, TransactionQuantity: Integer, GrandTotal: Decimal

Data Type:

ProductID: Integer, ProductName: Text, Quantity: Integer, Price: Decimal

Data Type:

TransactionID: Auto-increment Integer, ProductID: Integer, CustomerID: Integer, TransactionDate: Date, TransactionQuantity: Integer, GrandTotal: Decimal

Please write SQL statements (one SQL statement for each question) to solve the following questions based on the sample database:

- List customers Name, Job title and zip code for all the customers whose Zip code is between 95014 (included) and 95015 (included).

- List customer name, average purchase quantity (transaction quantity) and average purchase amount (i.e., grand total) for each customer (not including refunds).

- List all customers name for all customers who have made at least two transactions. (Transaction counts refer to how many transactions the customers have conducted. One transaction may include one or more than one transaction quantities).

- List all customers ID and name for the customers who have made no transaction in the year 2008. (Note: You may use subquery and NOT IN for this question. Please refer to SQL 26 and SQL 28 in the SQL slides. In both examples, we use IN. For this question, we should use NOT IN.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!