Write a SELECT statement that returns three columns: EmailAddress, OrderID, and the order total for each customer. To do this, you can group the result set by the EmailAddress and OrderID columns. In addition, you must calculate the order total from the columns in the OrderItems table.Write a second SELECT statement that uses the first SELECT statement in its FROM clause. The main query should return two columns: the customer’s email address and the largest order for that customer. To do this, you can group the result set by the EmailAddress column.

Answers

Answer 1
Answer:

Answer:

Select EmailAddress,max(total) from (Select EmailAddress, OrderID, sum(total) as total from OrderItems group by EmailAddress, OrderID) group by EmailAddress

Explanation:

First step is group the rows by email and order id and sum de total of orders

Select EmailAddress, OrderID, sum(total) as total from OrderItems group by EmailAddress, OrderID

Then you use the above query as a subquery grouping by the email and selecting the max value by client

Select EmailAddress,max(total) from (Select EmailAddress, OrderID, sum(total) as total from OrderItems group by EmailAddress, OrderID) group by EmailAddress


Related Questions

Do you think the current video game industry is likely to experience another “crash” (similar to the one in the 1980s) any time in the near future (next decade)? Why or why not? Offer at least two points that support your position.
I just started jGrasp using java. For some reason, there isn't a toolbar with the run buttons compile buttons, etc. Does anyone know how to make them show up?
calculate the size of a video file in terms of gb if each frame comprises of 512x512 pixels with 6 bits assigned per pixel with a frame rate of 24 fps and lasts for 30 minutes.
A program runs from start to finish, producing unexpected results, though no error message is received. What most likely occurred? (A.)a run-time error,(B.)a logic error,(C.)a syntax error,(D.)a message error
The recommended way to hold a loose hub on a fan is by

Jenny’s needs to buy a computer to create word documents, make presentations, listen to music, and watch movies and videos. Which operating system would be appropriate for Jenny’s personal computer?

Answers

Answer:

Windows

Explanation:

The operating system that would be appropiate for Jenny's personal computer is Windows as it is easy to use, the software and programs she is going to need are easily available to install in this operating system and it allows people to interact with it through keyboard and mouse.

Answer:

the answer is c) microsoft windows

Explanation:

What is a web server?

Answers

Its a server hosted by the computer its self its onot really online but the computer silulates a real server devoplers use it to test wb sites there making

You are concerned about your VMs receiving rogue DHCP servers. How can you prevent this from happening?

Answers

You are concerned about your VMs receiving rogue DHCP servers. In order for you to prevent this from happening, then with VMware, the solution is to set up the VMs as being "NAT" clients. This will set up a private network for the VMs, but will act as a gateway so that those VMs can interact with the rest of the network.

What is a variable? Why is it helpful in programming?

Answers

Answer:

Variables can represent numeric values, characters, character strings, or memory addresses. Variables play an important role in computer programming because they enable programmers to write flexible programs. Rather than entering data directly into a program, a programmer can use variables to represent the data.

Explanation:

If a student fails to recognize how to properly quote the words of an author, that student may be found guilty of _____. A. intentional plagiarism B.unintentional plagiarism C. intentional citation D. unintentional reference

Answers

B

Unintentional plagiarism is the act of quoting and forgetting to credit the author

Determine the result. Type "Error" if the program would terminate due to divide-by-zero. Only literals appear in these expressions to focus attention on the operators; most practical expressions include variables.100 / 2

Answers

Answer:

It depends upon the programming language that you are working on, and you can set your own error message using the try catch option. As an example, suppose you are working on the C#. Code like below can be added:

using System;

class MainClass {

static void Main(string[] args) {

int a = 5;

int b= 0;

int c= 100/2;

console.WriteLine(c);

try {

int d = a / b;

} catch (DivideByZeroException err) {

Console.WriteLine(err);

}

}

}

System.DivideByZeroException: Attempted to divide by zero.

This will give the above error message. And this is an error message by the system. We can also have a user-defined error message.

Explanation:

Please check the answer.