SP to return values with variabele

CREATE                         PROCEDURE TvaInventAgingSP

@variabele1 varchar(10),

@variabele2 varchar(10),

@variabele3 varchar(10)

 

AS

declare @1 integer

declare @2 integer

declare @3 integer

declare @4 integer

declare @5 integer

declare @6 integer

declare @7 integer

declare @8 integer

declare @9 integer

declare @10 integer

declare @11 integer

declare @12 integer

 

Set @1=

(

select sum([collumname]) FROM [aTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

 

Set @2=

(

select sum([collumname]) FROM [abTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @3=

(

select sum([collumname]) FROM [acTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @4=

(

select sum([collumname]) FROM [adTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @5=

(

select sum([collumname]) FROM [aeTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @6=

(

select sum([collumname]) FROM [afTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @7=

(

select sum([collumname]) FROM [agTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @8=

(

select sum([collumname]) FROM [ahTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @9=

(

select sum([collumname]) FROM [aiTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @10=

(

select sum([collumname]) FROM [ajTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @11=

(

select sum([collumname]) FROM [ahTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

Set @12=

(

select sum([collumname]) FROM [akTable]

where (jaar =@variabele1) AND (comp = @variabele2) AND (maand = '1') AND (item=@variabele3)

)

 

 

select @1 as maand1, @2 as maand2, @3 as maand3, @4 as maand4, @5 as maand5, @6 as maand6, @7 as maand7, @8 as maand8, @9 as maand9, @10 as maand10, @11 as maand11, @12 as maand12

 

GO


{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!