Query 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
Inquiry 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 Query A disregarding the Query B records.
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 do it?