Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
2| Name | Data Type | Length | Description |
|---|---|---|---|
| @p_Cuit | varchar | 20 | |
| @periodo | int | 4 |
SQL Script
Copy
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/*
exec [obtener_card_comex] '30500548041','2024'
exec [obtener_card_comex] '33697576849','2024'
*/
CREATE OR ALTER PROCEDURE dbo.obtener_card_comex
@p_Cuit varchar(20),
@periodo int
AS
BEGIN
SET NOCOUNT ON;
select 'IMPO' as tipo_operacion, sum(ROUND (fobusd,0)) as total_anual, @periodo as anio
from comex_importaciones
where cuit = @p_Cuit and SUBSTRING(cast(fecha as varchar(13)),0,5) = @periodo
union all
select 'EXPO' as tipo_operacion, sum(ROUND (fobusd,0)) as total_anual, @periodo as anio
--from comex_exportaciones
--where cuit = @p_Cuit and SUBSTRING(cast(fecha as varchar(13)),0,5) = @periodo
/* 24/01/2025: Porque hay muchos registros que se repiten muchas veces */
from (select distinct cuit, procedencia, fobusd, posicion, fecha
from comex_exportaciones
where cuit = @p_Cuit and SUBSTRING(cast(fecha as varchar(13)),0,5) = @periodo
) ce
/**/
END
GO
GO
/*
exec [obtener_card_comex] '30500548041','2024'
exec [obtener_card_comex] '33697576849','2024'
*/
CREATE OR ALTER PROCEDURE dbo.obtener_card_comex
@p_Cuit varchar(20),
@periodo int
AS
BEGIN
SET NOCOUNT ON;
select 'IMPO' as tipo_operacion, sum(ROUND (fobusd,0)) as total_anual, @periodo as anio
from comex_importaciones
where cuit = @p_Cuit and SUBSTRING(cast(fecha as varchar(13)),0,5) = @periodo
union all
select 'EXPO' as tipo_operacion, sum(ROUND (fobusd,0)) as total_anual, @periodo as anio
--from comex_exportaciones
--where cuit = @p_Cuit and SUBSTRING(cast(fecha as varchar(13)),0,5) = @periodo
/* 24/01/2025: Porque hay muchos registros que se repiten muchas veces */
from (select distinct cuit, procedencia, fobusd, posicion, fecha
from comex_exportaciones
where cuit = @p_Cuit and SUBSTRING(cast(fecha as varchar(13)),0,5) = @periodo
) ce
/**/
END
GO
Depends On
2Used By
No items found