Difficulty in select distinct sum

Asked

Viewed 190 times

1

My goal is to show 1 email with 1 total but I’m having difficulty I’ve tried that code:

SELECT DISTINCT email, totalcopias FROM dados
https://i.stack.imgur.com/IkU71.png

And I also tried this one:

SELECT DISTINCT email, totalcopias FROM dados GROUP BY email
https://i.stack.imgur.com/qa31d.png

But I’m not getting the totals together.

1 answer

1


You can try to do this way

SELECT email, MAX(totalcopias) as total FROM dados GROUP BY email

This query will show you the largest total of each email.

In case your need was to sum up all the copy totals, you would do so:

SELECT email, SUM(totalcopias) as total FROM dados GROUP BY email ORDER BY SUM(totalcopias)
  • was that thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.