USE [BeProd_REIMAN]
GO

/****** Object:  View [dbo].[USR_RST3_VIEW_SSCCs_Impressao]    Script Date: 25/10/2024 22:57:12 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE VIEW [dbo].[USR_RST3_VIEW_SSCCs_Impressao]
AS
SELECT        SSCC.strIA_00_SSCC, SSCC.strArtigoCodigo, SSCC.strArtigoDescricao, SSCC.strIA_10_Lote, SSCC.fltQtdActual, SSCC.dtmDataRegisto, SSCC.bitEliminado, SSCC.strCodArmazem, SSCC.strCodLocalizacao, SSCC.intIdEstadoAtual, 
                         SSCC.strDescEstado, SSCC.bitSSCCMisto, SSCC.strUser, SSCC.dtmDataRegisto AS Expr1, SSCC.dtmDataAlteracao, SSCC.strUserAlteracao, CAST(CASE WHEN ExpLin.strHashSublinha IS NULL THEN 0 ELSE 1 END AS bit) 
                         AS bitEmExpedicao, CASE WHEN ISNULL(EncLin.strCodArtigoCliente, '') = '' THEN SSCC.strArtigoCodigo ELSE ISNULL(EncLin.strCodArtigoCliente, '') END AS strQrTxt
FROM            dbo.Mov_SSCC_Cab AS SSCC LEFT OUTER JOIN
                         dbo.Mov_Expedicao_Lin AS ExpLin ON SSCC.strIA_00_SSCC = ExpLin.strSSCC LEFT OUTER JOIN
                         dbo.Mov_EncomendasCliente_SubLin AS EncSubLin ON ExpLin.strHashSublinha = EncSubLin.strHash LEFT OUTER JOIN
                         dbo.Mov_EncomendasCliente_Lin AS EncLin ON EncSubLin.strHashLinha = EncLin.strHash
GO

