Z
Z
Zakhar Storozhuk2017-04-13 15:46:14
MySQL
Zakhar Storozhuk, 2017-04-13 15:46:14

How to implement the plan using SQL?

How to implement the plan using SQL?
Task:
Display the sum of prices for each unique Email.
As I thought:

SELECT SUM(`price`) FROM `orders` WHERE `email` = (SELECT DISTINCT `email` FROM `orders`);

But in the end:
#1242 - Subquery returns more than 1 row

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Peter, 2017-04-13
@Phell

This is done through Group by

SELECT `email`, SUM(`price`) FROM `orders`
GROUP BY `email`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question