Subject | Temporary Tables in SP |
---|---|
Author | Tim Ledgerwood |
Post date | 2003-05-07T11:32:34Z |
I need to select the maximum value from a table given a certain select clause.
In Sybase, I would do something like the following :
SELECT * FROM BATCH
INTO
#TEMPTABLE
WHERE
BATCH_OPEN = 1;
This would create a temporary (in memory) table with the same structure as
BATCH, with values defined by the WHERE clause.
I could then say
SELECT MAX(BATCHNO) FROM BATCH INTO @MAXBATCH;
Where Maxbatch would be a variable
And end off by saying
SELECT * FROM BATCH WHERE BATCHNO = @MAXBATCH
Which would give me a singleton result that contains all the data from the
row where BATCH_OPEN = 1 and BATCHNO is the highest batch number in the
temporary table.
How could I accomplish the same thing in FB?
[Non-text portions of this message have been removed]
In Sybase, I would do something like the following :
SELECT * FROM BATCH
INTO
#TEMPTABLE
WHERE
BATCH_OPEN = 1;
This would create a temporary (in memory) table with the same structure as
BATCH, with values defined by the WHERE clause.
I could then say
SELECT MAX(BATCHNO) FROM BATCH INTO @MAXBATCH;
Where Maxbatch would be a variable
And end off by saying
SELECT * FROM BATCH WHERE BATCHNO = @MAXBATCH
Which would give me a singleton result that contains all the data from the
row where BATCH_OPEN = 1 and BATCHNO is the highest batch number in the
temporary table.
How could I accomplish the same thing in FB?
[Non-text portions of this message have been removed]