表:
deptId rodeCode workNo
1 A 123
1 B 456
2 A 123
2 B 456
3 A 123
3 B 456
.
.
.
1000 A 123
1000 B 456
要求 每个 deptId 追加一行 C 789
如:
1 A 123
1 B 456
1 C 789
2 A 123
2 B 456
2 C 789
以此类推 谢谢了,在线等!
deptId rodeCode workNo
1 A 123
1 B 456
2 A 123
2 B 456
3 A 123
3 B 456
.
.
.
1000 A 123
1000 B 456
要求 每个 deptId 追加一行 C 789
如:
1 A 123
1 B 456
1 C 789
2 A 123
2 B 456
2 C 789
以此类推 谢谢了,在线等!
select *
from(
select deptId,rodeCode,workNo from tb
union all
select distinct deptId,'C',789 from tb
)t
order by deptId
union all
select distinct
deptId
,rodeCode='C'
, workNo ='789'
from tab
order by 1,2
insert into tb(deptIdrodeCode,workNo)
select distinct deptId,'C',789 from tb
???
select distinct deptId,'C',789 from tb
select distinct deptId,'C',789 from tb