2
I made an appointment select
thus:
SELECT
data,
sexo,
idade,
count(*) qtd
FROM marcacao
group by data, sexo, idade
And return me a table similar to the table below:
DATA | SEXO | IDADE | QTD
01/07/2017 | F | 30 | 3
01/07/2017 | F | 33 | 2
02/07/2017 | F | 45 | 4
03/07/2017 | F | 51 | 5
I want to make a select
on the basis of select
previous, and I need to filter by dates and by age group, it would be something +- like this:
SELECT (Select_anterior)
where data >= dataini and data <= dataini
And the result should come out by age group, ex:
FAIXA ETARIA | SEXO | QTD
0 - 10 | F | 30
11 - 20 | F | 22
21 - 30 | F | 13
31 - 40 | F | 28
I do not know if it is possible to do something like this. I hope you have understood my doubt, but I can change the question if it is necessary.
You need to group the results one
case when
or the functionif()
can help.– rray
can show an example?
– Italo Rodrigo