select MAX (cast (id as numeric)) from table --whatever value it may return
select
(row_number () over (order by id)) as Number from table --will start at 1
How do I combine the two so whatever value the first query returns, I can use that value and auto increment from there, somehow combining the two (tried nesting them, but unsuccessful) or do I need to...
- Declare a variable
- get my max id value
- make my variable equal to that
- then place that value/variable in my second statement?
Like...
select
(row_number () over (order by id) + (declared_max_value)) as Number from table