Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MYSQL DATABASE: 2. Write a query that lists all members that have placed orders

ID: 3730413 • Letter: M

Question

MYSQL DATABASE:

2. Write a query that lists all members that have placed orders and the total amount spent per customer with the following criteria: a. An order amount greater than the average order amount for all customers. b. Consider only orders placed in July 1997. c. Make sure that the member considered has not returned any items. Note: You may need to populate some of the tables with sample data to see a result

3. Using the tables available to you in the TABLES section on D2L, create your own complex query. List the criteria that it addresses in the same format as Question 2. Show the output and explain why such a query would be useful. Try to reference at least 3 tables and use one or two columns from those tables. The query should try to involve concepts such as: functions, mathematical calculations, subqueries, and formatting to ensure it is complex enough.

Explanation / Answer

Solution:

The first question is done as per Chegg guidelines, please repost others.

2)

a)

SELECT orderAmount FROM Customers WHERE orderAmount> AVG(orderAmount)

Explanation:

The above query is using AVG aggregate function to get the average of the order amount and where condtion will give us the desired output.

b)

SELECT oderID FROM Oder WHERE orderDate= 'July 1997'

c)

SELECT CUSTOMERid FROM Customers WHERE return_status IS NULL

I hope this helps if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote