1
Consultation A:
SELECT V.CHAPA AS CHAPA,
F.NOME AS NOME,
V.DATA AS DATA,
DATEDIFF(mi, MIN(BATIDA), MAX(BATIDA)) AS DIFF
FROM V_BATIDASANTIGAS AS V
LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA = F.CHAPA
WHERE V.BATIDA IS NOT NULL
AND SEQUENCIALBATIDA IN (2,
3)
AND MONTH (V.DATA) = 9
GROUP BY V.CHAPA,
V.DATA,
F.NOME
HAVING DATEDIFF(mi, MIN(BATIDA), MAX(BATIDA)) < 60
AND DATEDIFF(mi, MIN(BATIDA), MAX(BATIDA)) > 0
ORDER BY DATA DESC
Query B:
SELECT V.CHAPA AS CHAPA,
F.NOME AS NOME,
V.DATA AS DATA,
V.CODCOLIGADA
FROM V_BATIDASANTIGAS AS V
LEFT JOIN V_DADOSFUNC AS F ON V.CHAPA = F.CHAPA
WHERE V.BATIDA IS NOT NULL
AND V.CODCOLIGADA = 1
GROUP BY V.CHAPA,
V.DATA,
F.NOME,
V.CODCOLIGADA
HAVING (MAX(V.SEQUENCIALBATIDA) > 4
OR MAX(V.SEQUENCIALBATIDA) = 1)
ORDER BY DATA DESC
I need to display the result of Consultation A disregarding the records of Query B.
An example would be something like:
IF (Relsultado_Consulta_A == Relsultado_Consulta_B)
BEGIN DECARTAR RESULTADOS IGUAIS
END
ELSE
BEGIN MOSTRA RESULTADOS QUE EXISTEM APENAS NA CONSULTA A
END
How could I ?
From what I understand you want the values in
A
who are not inB
, right? Is there any particular column, or are they all?– Marconi