SQL2000想在表里插入一万条记录 每1000条为一组并创建新的组名,这样的语句怎么写?

例如1-1000 部门1 1001-2000 部门2..... 部门N
2025-02-24 04:02:33
推荐回答(1个)
回答1:

insert 表(id,部门) select id,
case
when id>=1 and id<=1000 then '部门1'
when id>1000 and id<=1000 then '部门2'
...
else then '部门N'
end from 表 where