I need to do an if in postgres example.
SELECT
log."data" AS log_data,
log."tipomovimento" AS log_tipomovimento,
log."nomefornecedor" AS log_nomefornecedor,
log."nomeproduto" AS log_nomeproduto
FROM
"public"."log" log
WHERE
if(log."nomefornecedor" != null) {
log."data" BETWEEN '2018-01-01' and '2018-06-30'
and log."tipomovimento" IN ('S') and
"nomefornecedor" = 'x';
}else{
log."data" BETWEEN '2018-01-01' and '2018-06-30'
and log."tipomovimento" IN ('S')
}
If the provider is not null it will filter vendor, if it is null it will not filter vendor in the where. Anyone have any ideas?