I was researching how to make a subquery in the select clause with Criteria of a select of this type:
SELECT tabela1.*,tabela2.*,
(SELECT MAX(tabela5.AtrDatatabela5)
FROM .Tabela3 AS tabela3
INNER JOIN Tabela4 AS tabela4 ON tabela4.AtrIdTabela4 = tabela3.AtrIdTabela4
LEFT outer JOIN CraMar AS tabela5 ON tabela5.AtrIdTabela4 = tabela4.AtrIdTabela4
WHERE tabela4.AtrIdTipoTabela4 = 1
AND tabela3.AtrIdTabela2 = tabela2.atridTabela2
AND tabela3.AtrDataDevolucao IS NULL
AND tabela5.AtrDataTabela5 between 'Mar 29 2016 00:00' and 'Mar 29 2016 23:59'
AND tabela5.AtrCodigoTabela5 IN ('E', 'S')) as utlimaTabela5
FROM Tabela1 AS tabela1...