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

Genrate the SQL commands to create the following output: Quite often we need cre

ID: 3829514 • Letter: G

Question

Genrate the SQL commands to create the following output:

Quite often we need created computed values. We don't want to store these in the database (unnecessary) so we often generated them "on the fly" Using your previous query, create new column is the average order value (sum/total number of orders). Don't use the AVG() function. Your data should look like: Customer #000000001 1 1428873.61 9 158763.734444 Customer 000000002 2 1156504.92 10 115650.492000 Customer #000000004 4 4134567.39 31 133373.141613 Customer #000000005 5 1084042.74 9 120449.193333 Customer #000000007 7 3922020.98 24 1634 17.540833 Where column 4 is the average order value. In your SELECT statement you can created this computed column by enclosing your "field math" in parenthesis- (field_name/10*200).

Explanation / Answer

In this we are retrieving customer name,key and sum (order_amount) will give the sum of total amount of orders ordered by customer . And then the average amount of orders which is calculated by dividing the total amount from the no of orders ordered by customer.

And to get this data accurately for each customer we use group by Clause which the all the individual customer information.

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