SQL Select max is not working well

Asked

Viewed 51 times

0

I have this code but it’s not working well I don’t know why: inserir a descrição da imagem aqui

SELECT email, MAX(a4cor) as a4c, MAX(a4preto) as a4p, MAX(a3cor) as a3c, MAX(a3preto) as a3p, MAX(totalcopias) as total FROM dados GROUP BY email

I don’t know why you’re not adding up correctly:

inserir a descrição da imagem aqui

  • [email protected] was supposed to show 25 30 20 40 115

  • pq 25? by your example the a4cor max I see is 20! is not confusing max with sum?

  • I was confusing the code was sum instead of max

1 answer

-1


The MAX() takes the higher value. If you want the sum, you must use the SUM()

  • That was it, but yesterday I had this and it was working weird but thank you

  • 1

    should work because it only had one value and by chance it was the maximum :)

  • Why did my reply get -1? I did something wrong?

Browser other questions tagged

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