Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DECLARE @TdaInicial BIGINT = 1
- DECLARE @TdaFinal BIGINT = 2
- DECLARE @FechaInicial DATETIME = ''
- DECLARE @FechaFinal DATETIME = ''
- SELECT
- T.Tda_Codigo, T.Tda_Alias,
- CZ.CZ_Fecha, CZ.FolTda_Codigo, CZ.FolEst_Codigo, CZ.FolDoc_Codigo, CZ.FolConsecutivo,
- CONCAT(CZ.FolTda_Codigo, '-', CZ.FolEst_Codigo, '-', CZ.FolDoc_Codigo, '-', CZ.FolConsecutivo) AS FolioCZ,
- F.F_ImporteTotal, F.F_Fecha,
- F.FolTda_Codigo, F.FolEst_Codigo, F.FolDoc_Codigo, F.FolConsecutivo,
- CONCAT(F.FolTda_Codigo, '-', F.FolEst_Codigo, '-', F.FolDoc_Codigo, '-', F.FolConsecutivo) AS FolioF,
- FCFD.UUID
- FROM CortesZ CZ
- LEFT JOIN Facturas F ON F.CZTda_Codigo = CZ.FolTda_Codigo AND F.CZEst_Codigo = CZ.FolEst_Codigo AND F.CZDoc_Codigo = CZ.FolDoc_Codigo AND F.CZConsecutivo = CZ.FolConsecutivo
- LEFT JOIN FacturaCFD FCFD ON FCFD.FaTda_Codigo = F.FolTda_Codigo AND FCFD.FaEst_Codigo = F.FolEst_Codigo AND FCFD.FaDoc_Codigo = F.FolDoc_Codigo AND FCFD.FaConsecutivo = F.FolConsecutivo
- INNER JOIN Tiendas T ON T.Tda_Codigo = CZ.FolTda_Codigo
- WHERE T.Tda_Codigo BETWEEN @TdaInicial AND @TdaFinal AND CZ.CZ_Fecha BETWEEN @FechaInicial AND @FechaFinal
- --LEFT JOIN FacturasGlobalesCortesZ FGCZ ON FGCZ.FolTdaCodigo_CZ = CZ.FolTda_Codigo AND FGCZ.FolEstCodigo_CZ = CZ.FolEst_Codigo AND FGCZ.FolDocCodigo_CZ = CZ.FolDoc_Codigo AND FGCZ.FolConsecutivo_CZ=CZ.FolConsecutivo
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement