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
Amy would like to find all records that were delivered on August 8, 2008. Her database has a field that tracks when the items we
denpristay [2]
Conduct a query and set the criteria as = August 8, 2008. I'm not sure if this is the right answer, but that's what I think it is.
7 0
3 years ago
Read 2 more answers
A victimless crime is committed when
Ksju [112]
Someone downloads a pirated song or video a copyrighted image is used without permission and a person downloads and uses pirated software.
3 0
2 years ago
What is a Type 10 SD card?
Semmy [17]

Answer: Class 10 refers to the read write speed of a memory card

Explanation:

5 0
1 year ago
Write a statement that declares a PrintWriter reference variable named output and initializes it to a reference to a newly creat
dusya [7]

Answer:

PrintWriter variable = new PrintWriter("output.txt");

Explanation:

There are two ways of declaring a reference variable in programming.

One way is

Reference Variable-name = new Reference ("some texts here");

While the other is

Reference Variable-name;

Variable-name = new Reference ("some texts here");

Both ways are valid ways of reference variable declaration.

In the question above, the reference is PrintWriter, it points to output.txt and the question says "write a single statement";

Hence, we make use of

PrintWriter variable = new PrintWriter("output.txt");

A reference variable is declared to be of a specific type and that type can never be changed.

5 0
3 years ago
What is the definition of podcast
Yanka [14]

a digital studio that is been live to all around the world

6 0
3 years ago
Other questions:
  • Yesterday Hunter's laptop screen appeared to go black. The laptop was still running, but he could not see the desktop or any gra
    9·1 answer
  • 20. Which of the following describes an acceptable print resolution?
    10·2 answers
  • Liza works as a receptionist. Around the lunch hour, she has a difficult time hearing the callers due to employees talking near
    12·1 answer
  • What will be displayed if the following Java code segment is run? System.out.println("one "); System.out.print("two "); System.o
    12·1 answer
  • Write a C++ function using recursion that returns the Greatest Common Divisor of two integers. The greatest common divisor (gcd)
    14·1 answer
  • Microsoft Word, Google Chrome, and Windows Media Player are examples of
    15·1 answer
  • What does NBT stand for?​
    11·1 answer
  • Chris is working with other employees on a worksheet. the other employees have made comments, but they are not visible.
    11·1 answer
  • Look at the logic program below. Set a breakpoint after each commented instruction. You can also single step through the program
    13·1 answer
  • Which port security violation mode does not generate messages or increment the violations counter?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!