0
Good evening, I’m with a doubt I have a system that runs to seguiten query:
SELECT IDUsuario ,COUNT('TotalDeUps') as Total, FROM uploads
WHERE Time >= '2018-02-20 00:00:00'
AND Time < '2018-03-21 00:00:00'
GROUP BY IDUsuario
ORDER BY COUNT("UserID") DESC
I have inside this table uploads a column called Size , I wonder if I can add the values of the size of an ID to return , I thought something like this just didn’t work:
SELECT IDUsuario ,COUNT('TotalDeUps') as Total,SUM(Size) as TotalDeUp FROM uploads
WHERE Time >= '2018-02-20 00:00:00'
AND Time < '2018-03-21 00:00:00'
GROUP BY IDUsuario
ORDER BY COUNT("UserID") DESC
The result was zero in all columns.
Maybe you have some record
NULL
, utilizeCOALESCE
to see if that’s the problem:SUM(COALESCE(Size, 0))
– Sorack
It worked, thanks a lot. In case there was no null value in any column the SUM(Size) would work?
– reigelado
yes, it would work
– Sorack
Put your answer so I give Ok, thank you!
– reigelado