tags:

views:

40

answers:

1

Perhaps I'm trying to be too clever for my own good, and I could possibly use a scalar variable to solve this. I'm trying to add 1 to my output from the subquery;

INSERT INTO bookrevisiontbl (revisionnum, bookdate)
SELECT SUM(MAX(revisionnum) + 1), GETDATE() FROM bookrevisiontbl_tbl

However the following error occurs

Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

Is this query possible, and for it to maintain

+5  A: 
INSERT INTO bookrevisiontbl (revisionnum, bookdate)
SELECT MAX(revisionnum) + 1, GETDATE() FROM bookrevisiontbl_tbl 

No need for sum as max will return single value

Mark PM
@wonea, did you think about setting some sort of an auto_increment integer to `revisionnum`?
eumiro
Agreed, I'm a little embrassed. ;-)
wonea