1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Mila [183]
3 years ago
10

Write a SELECT statement that returns one row for each customer that has orders with these columns:

Computers and Technology
1 answer:
d1i1m1o1n [39]3 years ago
7 0

Answer:

SELECT email_address,

SUM(item_price * Quantity) AS item_price_total,

SUM(discount_amount * Quantity) AS discount_amount_total

FROM Customers c

JOIN Orders o ON c.CustomerID = o.CustomerID

JOIN Order_Items oi ON o.OrderID = oi.OrderID

GROUP BY email_address

ORDER BY item_price_total DESC

Explanation:

In this SQL statement the SELECT statement selects the following columns:

email_address

item_price

Quantity

discount_amount

There are two tables Customers and Order_Items

SUM aggregate function is used to add the values of the product of the columns discount_amount and Quantity. It is also used to get the sum of the product of two columns discount_amount and Quantity.

A new temporary column named item_price_total is used to name the sum of the product of two columns discount_amount and Quantity using AS which is ALIAS and it is used to give a name to some columns or a table.

Similarly discount_amount_total name is given to the column which calculate the sum of the product of two columns i.e. discount_amount and Quantity.

JOIN is used here to join the columns from the tables Order_items and Customers.

GROUP BY is used to group the result of rows and is used with functions like SUM. Here the rows are grouped by the email address.

ORDER BY is used to order the result. Here the result is ordered by item_price_total in descending  order.

This SELECT statement can also be written as following:

SELECT c.email_address,

SUM(o.item_price * o.Quantity),

SUM(o.discount_amount * o.quantity)

FROM customer c

JOIN Order_Items o ON o.id = c.id

GROUP BY c.email_address

You might be interested in
____________________________ and _________________________ are 2 positive impacts of the internet on businesses.
ZanzabumX [31]
D improved comms and easy ads
4 0
3 years ago
Read 2 more answers
When using color in a computer - generated presentation aids you should use?
Temka [501]
<span>the answer is: the same background color on all visuals and no more than two colors for words.</span>
6 0
2 years ago
click attachment to see correct answer. Which agencies run the Landsat Program? The Landsat program is run by ___ and ___.​
Ksju [112]

Answer:

ancient times were nicr

Explanation:

5 0
2 years ago
To define constructors and member functions outside of a class's original scope, the operator can be used.
Artyom0805 [142]

Answer: Scope resolution operator(::)

Explanation: A member function and the constructor can be called within the function easily but for the execution of the these components outside the class , a special operator is required to call the functions. The scope resolution operator(::) preceding with the name of class is thus used for defining of the function outside class.This operator maintains the cope of the function and constructor outside the class.

8 0
2 years ago
Which hardware device connects your network to the internet?
pentagon [3]
The Ethernet Cord 

Hope this helps,

kwrob :)

6 0
3 years ago
Other questions:
  • What is the output after the following code executes?
    14·1 answer
  • What is the top folder of the file tree called
    5·2 answers
  • Can you get financial aid with average grades
    15·1 answer
  • What is the definition of software? Group of answer choices an instruction that causes a single specific action to be performed
    11·1 answer
  • We already know that we can create a lunar lander application of the pipe-and-filter architecture style from three independent J
    6·1 answer
  • This project involves writing a program that encodes and decodes messages. The program should prompt the user to select whether
    15·1 answer
  • What is software piracy?
    11·1 answer
  • The Internet began when a large company wanted to sell products online.
    11·2 answers
  • Learning Task 3: Write the safety requirement indicated in each number on a
    15·1 answer
  • What are the data type(s) will be used to declare the variable(s) needed to
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!