January 30, 2014 at 1:59 pm
A working if statement is needed.
CREATE PROCEDURE [IncCondense] (@latin INT) AS
DECLARE @max-2 INT, @min-2 INT, @col3 INT, @datetime DATETIME;
SET @datetime = Getdate();
SELECT @datetime;
INSERT INTO allcount (datetime,Latin) VALUES (@datetime,@latin)
SELECT @min-2=MIN(ida), @max-2=MAX(ida) FROM allcount;
IF (@max-@min)>200
SELECT @col3 = SUM(Latin) FROM allcount;
DELETE FROM allcount;
INSERT INTO allcount (datetime, Latin) VALUES (@datetime,@col3);
January 30, 2014 at 2:12 pm
Read about BEGIN in books online. Which statements do you expect to be executed when IF returns true?
For better assistance in answering your questions, please read this[/url].
Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]
January 31, 2014 at 3:20 am
CREATE PROCEDURE [IncCondense] ( @latin INT )
AS
BEGIN
DECLARE @max-2 INT
, @min-2 INT
, @col3 INT
, @datetime DATETIME;
SET @datetime = GETDATE();
SELECT @datetime;
INSERT INTO allcount ( datetime, Latin )
VALUES ( @datetime, @latin )
SELECT @min-2 = MIN(ida)
, @max-2 = MAX(ida)
FROM allcount;
BEGIN
SELECT @col3 = SUM(Latin)
FROM allcount;
DELETE FROM allcount;
INSERT INTO allcount ( datetime, Latin )
VALUES ( @datetime, @col3 );
END
END
GO
Something like this I would guess.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply