Well, as a beginner in SQL, I need some help. I need only bring records that have not been moved for more than two days.
The query below is bringing everyone without this condition. I even did a test using the datediff, but I'm not sure if that was the case.
Bringing all records to this condition
Qtde Data
5000 18-07-2017
5001 18-07-2017
5002 25-07-2017
However, it was only to bring those on the 18th, because it was more than 2 days ago compared to today's date. Below is the query I tried to do.
SELECT DISTINCT
S.SolID AS [Qtde - Chamados em Pausa],
MAX(CONVERT(DATE,T.TraData,103))
FROM Solicitacao S
LEFT JOIN Usuario U ON U.UsuID = S.UsuIDResponsavel
LEFT JOIN Tramite T ON T.SolID = S.SolID
WHERE S.VencimentoPausado = 1 AND
T.TraData < DATEDIFF ( DAY ,2, getdate())
group by s.SolID