0

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

1 Answer 1

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

No need for sum as max will return single value

Sign up to request clarification or add additional context in comments.

2 Comments

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.