I would like to create a table using a select statement and add a column with row numbers
So I'd like to write something like:
create table schema.table_w_rownumbers as
select
identity(1, 1) as nrum,
foo.*
from schema.initial_table as foo;
This worked for me!
create table schema.table_w_rownumbers as
select
row_number() over (partition by 1) as nrum,
foo.*
from schema.initial_table as foo;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With