string(1052) " from tablicitacao l inner join TabModLicita m on (l.NModalidade = m.IdModLicita) INNER JOIN (select DtAndamento, Descricao, NLicita, NSituacao from tablicitacaoandamento where IdLicitacaoAndamento IN (select max(IdLicitacaoAndamento) from tablicitacaoandamento group by NLicita)) j on (l.IdLicita = j.NLicita) INNER JOIN tabsituacaolicita s ON (j.NSituacao = s.IdSitacaoLicita) LEFT JOIN tabtipolicita t ON (l.NTipoLicit = t.IdTipoLicita) LEFT JOIN tablicitarepublic p ON (p.NLicita = l.IdLicita) LEFT JOIN tablicitalocais o ON (l.NLicitaLocais = o.IdLicitaLocais) WHERE Site = 'S' AND NModalidade IN ('7','9') AND ((Carona = '' or Carona is null)) AND ((ChamPublic = '' or ChamPublic is null)) AND ((l.DataPublicAviso <= CURDATE()) OR (l.DataPublicAviso IS NULL)) AND l.DtDelete IS NULL "