3
I have the following structure tb_boletim:
|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 make ONLY one sql that brings me in two ways, depending on parameter passed to the field "newsletter".
I can make a Where case like this?
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     |