Grouping datatime in selects and summing the elements of the search per day to perform a comparison of the days of a given month

Asked

Viewed 20 times

-1

I’m using the type datatime and trying to perform a select that counts emissions day-to-day to mount a comparison chart of the days of a given month.

However, when grouping the dates it is returning the repeated days and adding up only the emissions of a specific hour of such day.

select count(solicitacao as emissões, dataSituacao
   from certificado
   where status like 'EMITIDO%'
   and dataSituacao BETWEEN '2020-10-01' and '2020-10-31'
   group by dataSituacao
   order by count(solicitacao) desc;

Select e banco

2 answers

-1

Try the following:

select count(solicitacao) as emissões, DATE(dataSituacao) from certificado
where status like 'EMITIDO%' and DATE(dataSituacao)     
BETWEEN '2020-10-01' and '2020-10-31' group by DATE(dataSituacao) 
order by count(solicitacao) desc;

-2

I put it this way and it worked, vlw too!

select count(solicitacao) as emissões, DATE(dataSituacao) from certificado where status like 'EMITIDO%' and DATE(dataSituacao) BETWEEN '2020-10-01' and '2020-10-31' group by DATE(dataSituacao) order by count(solicitacao) desc;

Browser other questions tagged

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