July 21, 2002 at 11:26 am
I need the sum of multiple columns in a row.
The best way for me to go would be with a stored proc because I want to invoke the function from NI LabView.
Is there any possibility to address those columns by an index, so that I don't have to type col1+col2... (like excel sum command)?
Thanks for your help in advance
Peter
July 21, 2002 at 1:51 pm
Don't think so. Can you give an example in detail of what you need so I am sure I didn't miss something here.
"Don't roll your eyes at me. I will tape them in place." (Teacher on Boston Public)
July 25, 2002 at 9:45 am
I've a table which consists of a primary key field and 50 int fields. I need the sum of the 50 int fields for a row specified by the primary key.
CREATE PROCEDURE SP_ESL_ChkSchw
(
@TeilID bigint,
@TypID int
)
AS
DECLARE @sum int
DECLARE @erg int
DECLARE @KontAnz int
SET NOCOUNT ON
SELECT @sum =K1+K2+K3+K4+K5+K6+K7+K8+K9+K10+K FROM ESL_IstGeschw WHERE TeilID=@TeilID
SELECT @KontAnz=KontAnz FROM ESL_UT_Typ WHERE TypID=@TypID
IF @sum=@KontAnz
BEGIN
SET @Erg=1
/*RETURN 1*/
END
ELSE
BEGIN
SET @Erg=2
/*RETURN 0*/
END
SELECT @sum AS 'Wert', @KontAnz AS 'KontAnz', @erg AS 'Erg'
RETURN
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply