我现在要对一个表中的数据进行如下处理:
1.首先是添加一个"数量"的字段
2.该表中有些记录是重复的,如果记录没有重复,就在对应的"数量"字段中写入"1",如果有2条记录重复,则只保留一条记录,并在对应的"数量"字段中写入"2".........多条记录重复,如此类推....
谢谢
1.首先是添加一个"数量"的字段
2.该表中有些记录是重复的,如果记录没有重复,就在对应的"数量"字段中写入"1",如果有2条记录重复,则只保留一条记录,并在对应的"数量"字段中写入"2".........多条记录重复,如此类推....
谢谢
(
a int
)
insert into test
select 1 union all
select 2 union all
select 1 union all
select 3 union all
select 2 union all
select 2 union all
select 4
go
alter table test add count int
go
select a,count(*)as count into # from test group by a
truncate table test
insert into test select * from #
go
select * from test
go
drop table test,#/*
a count
----------- -----------
1 2
2 3
3 1
4 1
*/