Jump to content

RICARDOVS

Members
  • Content count

    1
  • Joined

  • Last visited

Community Reputation

0 Comum

About RICARDOVS

  1. Estou tentando rodar a consulta abaixo, porém está dando o erro "Sintaxe incorreta próxima à palavra-chave 'where'". Poderiam me ajudar? SELECT '3. CONTAS BANCARIAS' as OPERACAO, SBC.REFERENCIA as DTVENC, CTA.CODCTABCOINT COD, CTA.DESCRICAO, SANKHYA.OBTEM_SALDO_BANCO_TGFMBC(SBC.CODCTABCOINT,convert(DATETIME, :DTSALDO)+1) as SALDODODIA, SANKHYA.OBTEM_SALDO_BANCO_TGFMBC(SBC.CODCTABCOINT,convert(DATETIME, :DTSALDO)+1) as SALDOFIN FROM TGFSBC SBC,TSICTA CTA WHERE SBC.CODCTABCOINT=CTA.CODCTABCOINT AND SBC.REFERENCIA=(SELECT MAX(SBC2.REFERENCIA) from TGFSBC SBC2 where SBC2.CODCTABCOINT=CTA.CODCTABCOINT) AND CTA.AD_EXIBE_BI='S' UNION ALL select * from (select '1. CAMBIAL PENDENTE' AS OPERACAO, MAX(FIN.DTVENC) AS DTVENC, NAT.CODNAT AS COD, nat.descrnat AS DESCRICAO, sum(VLRCAMBIAL) AS SALDODODIA, sum(vlrdesdob) as SALDOFIN from tgffin FIN JOIN AD_CAMBIAL CAM ON (CAM.NUFIN=FIN.NUFIN) join tgfnat nat on (nat.codnat=fin.codnat) where CAM.TIPO='P' group by nat.descrnat, NAT.CODNAT, '1. CAMBIAL PENDENTE') s where :OPERACAO='1. CAMBIAL PENDENTE' UNION ALL select * from (select '2. CAMBIAL DISPONIVEL' AS OPERACAO, MAX(FIN.DTVENC) AS DTVENC, NAT.CODNAT AS COD, nat.descrnat AS DESCRICAO, sum(VLRCAMBIAL) AS SALDODODIA, sum(vlrdesdob) as SALDOFIN from tgffin FIN JOIN AD_CAMBIAL CAM ON (CAM.NUFIN=FIN.NUFIN) join tgfnat nat on (nat.codnat=fin.codnat) where CAM.TIPO='D' group by nat.descrnat, NAT.CODNAT, '2. CAMBIAL DISPONIVEL') s where :OPERACAO='2. CAMBIAL DISPONIVEL' UNION ALL select * from (select '4. MOVIMENTO' AS OPERACAO, MAX(FIN.DTVENC) AS DTVENC, NAT.CODNAT AS COD, nat.descrnat AS DESCRICAO, sum(fin.vlrdesdob*fin.recdesp) AS SALDODODIA, sum(fin.vlrdesdob*fin.recdesp) AS SALDOFIN from tgffin FIN join tgfnat nat on (nat.codnat=fin.codnat) INNER JOIN TGFTOP TOC ON (FIN.CODTIPOPER = TOC.CODTIPOPER AND FIN.DHTIPOPER = TOC.DHALTER) LEFT JOIN AD_CAMBIAL CAM ON (CAM.NUFIN=FIN.NUFIN) AND TOC.DHALTER = (SELECT MAX(TOC.DHALTER) FROM TGFTOP TOC WHERE FIN.CODTIPOPER= TOC.CODTIPOPER) AND TOC.GRUPO<>:ADIANTAMENTOS where (FIN.DHBAIXA is null) AND FIN.CODEMP IN :EMPRESA AND (FIN.PROVISAO<>:PROVISAO) AND (FIN.CODTIPTIT<>19 AND FIN.CODTIPTIT<>20 AND FIN.CODTIPTIT<>21) and FIN.DTVENC=:DIA group by nat.descrnat, NAT.CODNAT, '4. MOVIMENTO') where :OPERACAO='4. MOVIMENTO'
×

Important Information

Ao usar o fórum, você concorda com nossos Terms of Use.