I've found answers online, but none with specifically what I am doing. I couldn't get anything to work.
I have a select that randomly selects records and I just want to be able to have it insert into a table instead.
My SQL is
with data as (
select *, row_number() over (partition by DIVISION order by DIVISION) as rn
from WORK
)
select *
from data
where rn <= @randomNumber or (rn - @randomNumber) % 18 = 1 AND DIVISION != 4;
I know I am not supposed to do the partition by DIVISION order by DIVISION but that's a separate issue I believe.
I just need to be able to insert this data into another table WORK_CLEAN
You just need to add an insert statement.
with data as (
select *, row_number() over (partition by DIVISION order by DIVISION) as rn
from WORK
)
insert yourTable ([ColumnsHere])
select *
from data
where rn <= @randomNumber or (rn - @randomNumber) % 18 = 1 AND DIVISION != 4;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.