1
I need to compare date in a certain time interval. I need to pick up the field DAT_REPOT_REALZ
and check the dates between TODAY and seven days ago. I also need to count the number of V (visitor) and the number of L (leader) and M (participant), at query
that I did didn’t work out because I’m not very familiar with sql
.
It is worth noting that I am using the MYSQL
.
I tried to do so
select case FLG_IDENT_PESSO when 'V' then count(FLG_IDENT_PESSO) when 'M' then count(FLG_IDENT_PESSO) end from tbl_PRESENCA WHERE FLG_IDENT_PRESE = 'S' and DAT_REPOT_REALZ <= now()-7
The structure of my table:
COD_IDENT_REUNI bigint(20) UN PK
COD_IDENT_PESSO bigint(20) UN PK
FLG_IDENT_PRESE char(1) //PODE SER S (presente) ou N (nao presente)
FLG_IDENT_PESSO char(1) // PODE SER V (visitantes) ou L (lider) ou ainda M (participante)
DAT_REPOT_REALZ datetime // É O DIA EM QUE FOI FEITO O REPORTE
You need to wear a
BETWEEN
or two checks inWHERE
to work the way you want.– DH.
What the query would look like?
– Renan Rodrigues