I have the following structure tb_bulletin:
|Cod|boletim|dt_enviado|
| 1 | N | NULL |
| 2 | S |24/08/2018|
| 3 | S | NULL |
| 4 | S |23/08/2018|
| 5 | S |23/08/2018|
| 6 | S | NULL |
| 7 | N | NULL |
| 8 | N | NULL |
I want to ONLY make an sql that brings me in two ways, depending on the parameter passed to the "bulletin" field.
Can I make a case in the where type?
select * from tb_boletim where
boletim = 'S' and
case
when boletim = 'S' then dt_enviado is not null
when boletim = 'N' then dt_enviado null
end
Expected result:
|Cod|boletim|dt_enviado|
| 2 | S |24/08/2018|
| 4 | S |23/08/2018|
| 5 | S |23/08/2018|
or
|Cod|boletim|dt_enviado|
| 1 | N | NULL |
| 7 | N | NULL |
| 8 | N | NULL |