0
I have the following sql query:
select nome, data, situacao from cadastro
The result is like this:
MARIA 01/01/2018 0
MARIA 15/01/2018 1
GISELE 15/01/2018 0
CICERA 08/01/2018 1
ANTONIA 20/01/2018 0
ANTONIA 15/01/2018 1
I need to do a distinct by name:
select distinct(nome), data, situacao from cadastro group by data, situacao
The problem is that it does not do the distinct because the dates are different, however, I need that when the patient has two charts (situation 0 and 1), only the chart with situation = 1.
In this case, it should generate the result like this:
MARIA 15/01/2018 1
GISELE 15/01/2018 0
CICERA 08/01/2018 1
ANTONIA 15/01/2018 1
Any suggestions?
can have more situations? 2,3,4 ? can the patient have two charts with situation 1 and different dates ?
– Rovann Linhalis
no, just 0 and 1 same @Rovannlinhalis
– Italo Rodrigo