Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
1| Name | Data Type | Length | Description |
|---|---|---|---|
| @cuit | varchar | 20 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE OR ALTER PROCEDURE dbo.obtener_comex_rubros_test
@cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
declare @max_periodo date,@min_periodo date
set @max_periodo = (select fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
set @min_periodo = (select DATEADD(month, -12, max(@max_periodo)) as fecha_informacion)
SELECT 'IMPO' as tipo_operacion, comex_rubros.descripcion,sum(ROUND (fobusd,0)) as fob FROM comex_importaciones
inner join comex_rubros on comex_rubros.rubro = comex_importaciones.posicion
WHERE CUIT = @cuit and fecha between @min_periodo and @max_periodo
group by descripcion
union all
SELECT 'EXPO' as tipo_operacion,descripcion,sum(ROUND (fobusd,0)) as fob FROM comex_exportaciones
inner join comex_rubros on comex_rubros.rubro = comex_exportaciones.posicion
WHERE CUIT = @cuit and fecha between @min_periodo and @max_periodo
group by descripcion order by tipo_operacion,fob desc
END
GO
GO
CREATE OR ALTER PROCEDURE dbo.obtener_comex_rubros_test
@cuit varchar(20)
AS
BEGIN
SET NOCOUNT ON;
declare @max_periodo date,@min_periodo date
set @max_periodo = (select fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
set @min_periodo = (select DATEADD(month, -12, max(@max_periodo)) as fecha_informacion)
SELECT 'IMPO' as tipo_operacion, comex_rubros.descripcion,sum(ROUND (fobusd,0)) as fob FROM comex_importaciones
inner join comex_rubros on comex_rubros.rubro = comex_importaciones.posicion
WHERE CUIT = @cuit and fecha between @min_periodo and @max_periodo
group by descripcion
union all
SELECT 'EXPO' as tipo_operacion,descripcion,sum(ROUND (fobusd,0)) as fob FROM comex_exportaciones
inner join comex_rubros on comex_rubros.rubro = comex_exportaciones.posicion
WHERE CUIT = @cuit and fecha between @min_periodo and @max_periodo
group by descripcion order by tipo_operacion,fob desc
END
GO
Depends On
4Used By
No items found