dbo.obtener_grafico_exportaciones_ant

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

1
Name Data Type Length Description
@p_Cuit varchar 20

SQL Script

Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO

CREATE OR ALTER PROCEDURE dbo.obtener_grafico_exportaciones_ant 
@p_Cuit varchar(20)
AS


BEGIN
       SET NOCOUNT ON;
   declare @max_periodo date,@min_periodo date
set @max_periodo  = (select max(fecha_informacion) as fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
set @min_periodo  = (select DATEADD(month, -24, max(fecha_informacion)) as fecha_informacion from fuentes_procesadas where fuente='comex_pais_rubro' and visible =1)
/*
select 
isnull(sum(round(fobusd,0)),0) as valor_mensual,
cuit,
convert(varchar(4), fecha)  as anio,
DATEPART(month,fecha)  as mes
 
from comex_exportaciones 
where cuit = @p_Cuit
and fecha between @min_periodo and @max_periodo
 
group by fecha,cuit order by fecha asc*/

  select
  isnull(sum(round(fobusd,0)),0) as valor_mensual,
  (CAST(YEAR(fecha) AS VARCHAR) + CAST(RIGHT(CONCAT('00',MONTH(fecha)),2) AS VARCHAR)) as periodo
  
  from comex_exportaciones 
  where cuit = @p_Cuit
  and fecha between @min_periodo and @max_periodo
   
  group by (CAST(YEAR(fecha) AS VARCHAR) + CAST(RIGHT(CONCAT('00',MONTH(fecha)),2) AS VARCHAR)) 

/*

[obtener_grafico_exportaciones] '30501677643'


select round(fobusd,0) as fob,fecha from comex_exportaciones where cuit = '30501677643' order by fecha
*/

END

GO

Used By

No items found