string(1995) " from ( SELECT e.IdLCEmpenhos AS Id, e.DataEmpenho AS Data, e.NumEmpenho AS Numero, e.Valor AS Valo, e.Historico AS Histor, e.NomeFornecedor AS Fornecedor, e.CdUnidade AS CdUnidade, e.CdOrgao, 'EMPENHADO' AS TipoLC, e.Exercicio AS Exerc FROM TabLCEmpenhos e where e.TipoCredito = 'O' UNION all SELECT l.IdLCLiquidacoes AS Id, l.DataLiquidacao AS Data, e.NumEmpenho AS Numero, l.ValorLiquidacao AS Valo, e.Historico AS Histor, e.NomeFornecedor AS Fornecedor, e.CdUnidade AS CdUnidade, e.CdOrgao, 'LIQUIDADO' AS TipoLC, l.Exercicio AS Exerc FROM tablcliquidacoes l, TabLCEmpenhos E WHERE (L.NumEmpenho = E.NumEmpenho) AND (L.Exercicio = E.Exercicio) AND (e.TipoCredito = 'O') union all SELECT p.IdLCPagamentos AS Id, p.DataPagamento AS Data, e.NumEmpenho AS Numero, p.ValorPagamento AS Valo, p.Historico AS Histor, e.NomeFornecedor AS Fornecedor, e.CdUnidade AS CdUnidade, e.CdOrgao, 'PAGO' AS TipoLC, p.Exercicio AS Exerc FROM tablcpagamentos p, TabLCEmpenhos E WHERE (p.NumEmpenho = E.NumEmpenho) AND (p.Exercicio = E.Exercicio) AND e.TipoCredito = 'O' ) AS ORDEMCRONO inner join (SELECT exercicio, codigo_orgao, CONCAT(codigo_orgao, ' - ', nome_orgao) AS Orgao FROM taborcorgao ORDER BY codigo_orgao) AS G ON (G.codigo_orgao = CdOrgao) WHERE Exerc = G.exercicio "