Advertisement
brunobola

Untitled

Feb 2nd, 2023
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 1.39 KB | None | 0 0
  1. CREATE VIEW V_TRI_GuiasFormacao
  2. AS
  3. SELECT guia.CDU_Numero AS 'NGuia',
  4.        guia.CDU_Cliente AS 'NCliente',
  5.        cliente.Nome AS 'NomeCliente',
  6.        tecnico.Email AS 'EmailTecnico',
  7.        guia.CDU_DataInicio AS 'Data',
  8.        guia.CDU_NHoras AS 'Duracao',
  9.        guia.CDU_Problema AS 'DescricaoProblema',
  10.        guia.CDU_Servico AS 'DescricaoServico',
  11.        condicao.CDU_Descricao AS 'DescricaoCondicao',
  12.        intervencao.CDU_Descricao AS 'DescricaoTipoIntervencao',
  13.        problema.Descricao AS 'DescricaoTipoProblema'
  14. FROM dbo.TDU_GuiasAssistencia guia WITH (NOLOCK)
  15.     LEFT JOIN dbo.Clientes cliente WITH (NOLOCK)
  16.         ON cliente.Cliente = guia.CDU_Cliente
  17.     LEFT JOIN dbo.Tecnicos tecnico WITH (NOLOCK)
  18.         ON tecnico.Tecnico = guia.CDU_Tecnico
  19.     LEFT JOIN dbo.TDU_CondicoesInterv condicao WITH (NOLOCK)
  20.         ON condicao.CDU_Codigo = guia.CDU_Condicoes
  21.     LEFT JOIN dbo.TDU_TipoInterv intervencao WITH (NOLOCK)
  22.         ON intervencao.CDU_Codigo = guia.CDU_TipoInterv
  23.     LEFT JOIN dbo.TiposProblemas problema WITH (NOLOCK)
  24.         ON problema.TipoProblema = guia.CDU_TipoProblema
  25. WHERE guia.CDU_DataInicio >= '2023-01-01'
  26.       AND
  27.       (
  28.           guia.CDU_Servico COLLATE Latin1_general_CI_AI LIKE '%Formação%'
  29.           AND guia.CDU_Servico COLLATE Latin1_general_CI_AI NOT LIKE '%Informação%'
  30.       )
  31.       AND guia.CDU_Condicoes IN ( 0, 1, 2, 3, 5 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement