Can you use MAX() to assign value in insert into select?

Hello, just for testing purposes, I want to duplicate all records in table BOOK. I am trying to use MAX function to assign ID of previous row to PREVIOUS_ID column of newly created row.

INSERT INTO BOOK ([NAME], PREVIOUS_ID)

SELECT [NAME], MAX(ID) FROM BOOK

I am getting following error:

Column ‘BOOK.NAME’ is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.

Is there a way to use MAX function in this query?

submitted by /u/Historical-Run7505
[link] [comments]


Go to Source of this post
Author Of this post: /u/Historical-Run7505
Title Of post: Can you use MAX() to assign value in insert into select?
Author Link: {authorlink}