string(1246) " 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) INNER JOIN tablicitalocais o ON (l.NLicitaLocais = o.IdLicitaLocais) LEFT JOIN tabtipolicita t ON (l.NTipoLicit = t.IdTipoLicita) LEFT JOIN tablicitarepublic p ON (p.NLicita = l.IdLicita) LEFT JOIN (select NLicita, group_concat(t2.Descricao separator ', ') as GroupSec, NSec from tablicitaorgao t inner join tabsecretarias t2 on (t.NSec = t2.IdSecretarias) group by NLicita ) g on (g.NLicita = l.IdLicita) where Site = 'S' AND NModalidade NOT 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 "