Subject VIEW CREATES ON FB 2.5 BUT DO NOT CREATE ON FB 1.5
Author Israel Pinheiro
Please,



CREATE OR ALTER VIEW ESPELHO12(

CODEMPRESA,

CODFILIAL,

DTMOVPROD,

CODMOVIMENTO,

CODPRODUTO,

TIPOMOVIMENTO,

QUANTIDADE,

SALDO,

CFOP,

CODCOMPRA,

CODVENDA,

DESCRICAO,

NCM,

DOCUMENTO,

TIPOPRODUTO,

CUSTO,

TMEMPRESA,

TMFILIAL,

NOMERAZAOTIPO

)

AS

SELECT

MP.CODEMP,

MP.CODFILIAL,

MP.DTMOVPROD,

MP.CODMOVPROD,

MP.CODPROD,

MP.CODTIPOMOV,

MP.QTDMOVPROD,

MP.SLDMOVPROD,

MP.CODNAT,

MP.CODCOMPRA,

MP.CODVENDA,

EQ.DESCPROD,

EQ.CODFISC,

MP.DOCMOVPROD,

EQ.TIPOPROD,

CAST((MP.sldmovprod*EQ.CUSTOINFOPROD) AS NUMERIC(15,2)) CUSTO,

TM.CODEMP AS TMEMP,

TM.CODFILIAL AS TMFIL,

TM.DESCTIPOMOV

FROM EQMOVPROD MP

INNER JOIN EQPRODUTO eq on mp.codprod = eq.codprod

LEFT JOIN eqtipomov tm on tm.codtipomov = mp.codtipomov

where MP.CODEMP=TM.CODEMP AND MP.CODFILIAL=TM.CODFILIAL AND

MP.CODTIPOMOV=TM.CODTIPOMOV AND tipoprod='P' and mp.codvenda is null and
mp.codcompra is null



GROUP BY

MP.DTMOVPROD,

MP.CODTIPOMOV,

MP.CODMOVPROD,

MP.CODPROD,

MP.CODNAT,

MP.DOCMOVPROD,

MP.CODCOMPRA,

MP.CODVENDA,

EQ.DESCPROD,

EQ.TIPOPROD,

MP.CODEMP,

MP.CODFILIAL,

TM.CODEMP,

TM.CODFILIAL,

MP.QTDMOVPROD,

MP.SLDMOVPROD,

EQ.CODFISC,

EQ.CUSTOINFOPROD,

TM.DESCTIPOMOV







UNION ALL

SELECT

MP.CODEMP,

MP.CODFILIAL,

MP.DTMOVPROD,

MP.CODMOVPROD,

MP.CODPROD,

MP.CODTIPOMOV,

MP.QTDMOVPROD,

MP.SLDMOVPROD,

MP.CODNAT,

MP.CODCOMPRA,

MP.CODVENDA,

EQ.DESCPROD,

EQ.CODFISC,

MP.DOCMOVPROD,

EQ.TIPOPROD,

CAST((MP.sldmovprod*EQ.CUSTOINFOPROD) AS NUMERIC(15,2)) CUSTO,

TM.CODEMP AS TMEMP,

TM.CODFILIAL AS TMFIL,

FORN.RAZFOR AS NOMEFORNECEDOR

FROM EQMOVPROD MP, EQTIPOMOV TM

INNER JOIN EQPRODUTO eq on mp.codprod = eq.codprod

LEFT JOIN cpcompra cp on mp.codcompra = cp.codcompra

LEFT JOIN cpforneced forn on cp.codfor =forn.codfor

where MP.CODEMP=TM.CODEMP AND MP.CODFILIAL=TM.CODFILIAL AND

MP.CODTIPOMOV=TM.CODTIPOMOV AND tipoprod='P' and mp.codvenda is null and
mp.codcompra is not null



GROUP BY

MP.DTMOVPROD,

MP.CODTIPOMOV,

MP.CODMOVPROD,

MP.CODPROD,

MP.CODNAT,

MP.DOCMOVPROD,

MP.CODCOMPRA,

MP.CODVENDA,

EQ.DESCPROD,

EQ.TIPOPROD,

MP.CODEMP,

MP.CODFILIAL,

TM.CODEMP,

TM.CODFILIAL,

MP.QTDMOVPROD,

MP.SLDMOVPROD,

EQ.CODFISC,

EQ.CUSTOINFOPROD,

FORN.RAZFOR



UNION ALL

SELECT

MP.CODEMP,

MP.CODFILIAL,

MP.DTMOVPROD,

MP.CODMOVPROD,

MP.CODPROD,

MP.CODTIPOMOV,

MP.QTDMOVPROD,

MP.SLDMOVPROD,

MP.CODNAT,

MP.CODCOMPRA,

MP.CODVENDA,

EQ.DESCPROD,

EQ.CODFISC,

MP.DOCMOVPROD,

EQ.TIPOPROD,

CAST((MP.sldmovprod*EQ.CUSTOINFOPROD) AS NUMERIC(15,2)) CUSTO,

TM.CODEMP AS TMEMP,

TM.CODFILIAL AS TMFIL,

cast(CLI.NOMECLI as char(60)) NOMECLIENTE

FROM EQMOVPROD MP, EQTIPOMOV TM

LEFT JOIN EQPRODUTO eq on mp.codprod = eq.codprod

LEFT join vdvenda vd on mp.codvenda=vd.codvenda

LEFT join vdcliente cli on vd.codcli = cli.codcli

where MP.CODEMP=TM.CODEMP AND MP.CODFILIAL=TM.CODFILIAL AND

MP.CODTIPOMOV=TM.CODTIPOMOV AND tipoprod='P' and mp.codcompra is null and
mp.codvenda is not null



GROUP BY

MP.DTMOVPROD,

MP.CODTIPOMOV,

MP.CODMOVPROD,

MP.CODPROD,

MP.CODNAT,

MP.DOCMOVPROD,

MP.CODCOMPRA,

MP.CODVENDA,

EQ.DESCPROD,

EQ.TIPOPROD,

MP.CODEMP,

MP.CODFILIAL,

TM.CODEMP,

TM.CODFILIAL,

MP.QTDMOVPROD,

MP.SLDMOVPROD,

EQ.CODFISC,

EQ.CUSTOINFOPROD,

CLI.NOMECLI

;





---
Este email foi escaneado pelo Avast antivĂ­rus.
https://www.avast.com/antivirus


[Non-text portions of this message have been removed]