dbo.Imperium_Info_Contratistas_Login

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE OR ALTER PROCEDURE dbo.Imperium_Info_Contratistas_Login 
 -- Add the parameters for the stored procedure here
 
AS
BEGIN
 -- SET NOCOUNT ON added to prevent extra result sets from
 -- interfering with SELECT statements.
 SET NOCOUNT ON;


select c.contratista as id, p.nombre_persona as contratista, p.numero as cuit,
c.estado_contratista as estado, 
case when subc.subcontratistas is not null then subc.subcontratistas else 0 end as cant_subcontratistas,
u.first_name as nombre, u.last_name as apellido, u.email, u.last_login as ultimo_acceso,
case when u.password = '@encripted' then 'SI' ELSE 'NO' end as cambio_contrasena
from led_contratistas c join users u on c.user_id = u.user_id
join padrones p on c.id_padron = p.id_padron
left join (select led_contratistas.contratista, count(*) as subcontratistas 
   from led_contratistas inner join led_contratistas sc on led_contratistas.contratista = sc.contratista_1
   where led_contratistas.cliente = 7048064
   and sc.contratista <> sc.contratista_1
   group by led_contratistas.contratista) subc on c.contratista = subc.contratista
where c.cliente = 7048064
order by p.nombre_persona

END

GO

Used By

No items found