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
In the previous project, you are storing the first name of the gamer. Write a phrase to the game right before the first word wit
hodyreva [135]

Answer:

Explanation:

Since the previous project code is not provided, what we can do is simply create the piece of code that does what the question is asking here and you can just add that to the previous project. I'll be assuming that the project was written in Java.

System.out.println("Are you ready to get started " + playerNameVariable + "?");

This line of code will ask the player if their "ready to get started?". It uses the playerNameVariable to state the name that the player had inputted previously. This line of code can be added to the previous project code right before the first word within the first paragraph of text

5 0
2 years ago
You use the _____ sheet in the format cells dialog box to position data in a cell by centering it, for example.​
Oliga [24]
You use the Alignment sheet in the format cells dialog box to position data in a cell by centering it, for example. Generally along the middle branch is a line or centerline of the definite pipeline on a scale of whatever is indicated.
3 0
2 years ago
Why is drafting important in every industry
saul85 [17]

The Writing Process- Drafting and Editing. Writing is a process that involves several distinct steps: prewriting, drafting, revising, editing, and publishing. It is important for a writer to work through each of the steps in order to ensure that he has produced a polished, complete piece.

5 0
3 years ago
The basic components of cartridges and shotshells are similar. Shot pellets and a bullet are examples of which basic component?
Liono4ka [1.6K]
The answer is projectile. Handguns and rifles use a cartridge having a single projectile or bullet. Shotguns use a shot shell comprising either a single bullet or a big number of small projectiles (shot or pellets). Though, the basic components of cartridges and shot shells are alike.
5 0
3 years ago
Please help
ExtremeBDS [4]

Answer:

Answered below

Explanation:

This solution is written in Kotlin programming language.

fun average (a: Int, b: Int, c: Int, d: Int, e: Int) : Double {

#variable to hold the addition of all parameters

var sum = a + b + c + d + e

#variable to hold the average of sum

var avg = sum / 5

return avg

}

#call the function to see how it works.

# this operation is done in the fun main()

var test: Double = average ( 5, 4, 7 , 3, 9)

print (test)

8 0
3 years ago
Other questions:
  • Brian is testing a banking application. He enters an input and expects a certain output. What is the actual output of the applic
    11·1 answer
  • Five computers are connected to a switch in a star topology. what type of network is this?
    12·1 answer
  • In regards to storing folders the computer can be described as a ________________.
    7·1 answer
  • Somebody who is good at this stuff, please halp meh ;-;
    6·1 answer
  • The color band that represents tolerance on a resistor is the?
    11·1 answer
  • Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is false. Print "Red balloon" i
    9·1 answer
  • What option do you use to view your presentation?
    15·1 answer
  • What is HTML? (list down any 5 points)
    12·1 answer
  • Which of the following is a valid c++ identifier a. mouse b. _int c. 2_stop d. float​
    10·1 answer
  • 30 Points!!
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!