0
I’m trying to set up a consult but it’s not bringing anything.
SELECT EMP, COD, VEV, SEQ, TIP, NUM, EMI, VEN, DTR, GRU, PRO, QTD, PVE, TOT, FAT, COM, COO, REF, VAR, hcli.NOM as "VENDEDOR",
hemp.enc from hcov
INNER JOIN hcli ON hcov.COD = hcli.COD
JOIN hemp ON hemp.cod = hcov.emp
WHERE (hcli.NOM NOT LIKE '%COOPERATIVA%')
AND (DTR >= date '2020-01-01')
AND (COD NOT IN (24545 ,10368 ,13149, 10448, 11041, 30610, 6834) )
AND (GRU <> 266 OR GRU <> 269 OR GRU <> 272)
AND ( (VEV <> 37125) AND (COO NOT IN (987209, 23631, 927500, 22763, 38736 ) ) )
AND (num = 84831 and emp = 24)
AND (hemp.enc <> hcov.cod)
The problem is in the last line of the consultation, because when I take it out it works.. but I need it for comparison. I’m actually riding the wrong way?
Any comparison with "null" returns as "false" a solution is something of the type AND ((Hemp.Enc <> hcov.Cod) or (hcov.Cod is null)) but needs to define well what to do in these cases , inform the DBMS because the treatment of null (nvl COALESCE isnull)
– Motta
but how I would then make this comparison and bring in the query only if COD is different from ENC ??
– Fernando Fefu
put this way that you spoke worked out... AND ((Hemp.Enc <> hcov.Cod) or (Hemp.Enc is null))
– Fernando Fefu