Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE VIEW V_TRI_AnaliseEstornoVendas
- WITH SCHEMABINDING
- AS
- SELECT cd.Id,
- cd.TipoDoc,
- cd.Serie,
- cd.NumDoc,
- cd3.TipoDoc AS 'TipodocEstorno',
- cd3.Serie AS 'SerieEstorno',
- cd3.NumDoc AS 'NumDocEstorno',
- cd3.DATA AS 'DataEstorno'
- FROM dbo.CabecDoc cd WITH (NOLOCK)
- INNER JOIN dbo.LinhasDoc ld WITH (NOLOCK)
- ON ld.IdCabecDoc = cd.id
- LEFT JOIN dbo.CabecDocStatus cs2 WITH (NOLOCK)
- ON cs2.IdCabecDoc = cd.id
- LEFT JOIN dbo.LinhasDoc ld3 WITH (NOLOCK)
- ON ld3.IDLinhaEstorno = ld.Id
- LEFT JOIN dbo.CabecDoc cd3 WITH (NOLOCK)
- ON cd3.Id = ld3.IdCabecDoc
- LEFT JOIN dbo.CabecDocStatus cs3 WITH (NOLOCK)
- ON cs3.IdCabecDoc = cd3.Id
- WHERE
- cd3.Id IS NOT NULL
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement