2\ ALERT TABLE TB_A ADD ID INT IDENTITY(1,1)
DELETE FROM TB_A WHERE ID
NOT IN(SELECT MIN(ID) ID FROM TB_A GROUP BY F_A)
1的条件
DELETE FROM TB_A WHERE ID
NOT IN(SELECT MIN(ID) ID FROM TB_A GROUP BY F_A)
1的条件
解决方案 »
- 求教!sql——结贴太快,麻烦
- 求查询语句的优化?
- 一条关于算法的问题,急,
- 关于作业失败的问题
- 运行程序时,用sqlserver事件探查器,发现有很多exec sp_reset_connection与exec sp_cursorfetch 18015000,16,n,n的过程执行.能不能优化
- 怎么写SQL语句?
- 急急!!!SQL触发器
- 一个菜鸟的存储过程问题,在线等。大侠救命啊
- 怎么样才能处理字段中的NULL值呢??请帮忙,谢谢!!
- [急]将sqlserver的一个表的数据随机取出50条导入access中,这个语句应该怎么写??
- 如何用SQL语言编写一段使字段[trx_code]自递增的程序
- 有关存储过程传递值的操作
1,select (select count(*) from 表 where f_a>=aa.f_a),f_b,f_c from 表 AA
---------------------
如果有ID字段,就是具有唯一性的字段delect table where id not in ( select max(id) from table group by col1,col2,col3...
)
group by 子句后跟的字段就是你用来判断重复的条件,如只有col1,那么只要col1字段内容相同即表示记录相同。2,如果是判断所有字段也可以这样
select * into #aa from table group by id1,id2,....
delete table
insert into table
select * from #aa3,没有ID的情况select identity(int,1,1) as id,* into #temp from tabel
delect # where id not in (
select max(id) from # group by col1,col2,col3...)
delect table
inset into table(...)
select ..... from #temp
col1+','+col2+','...col5 联合主键
select * from table where col1+','+col2+','...col5 in ( select max(col1+','+col2+','...col5) from table
where having count(*)>1
group by col1,col2,col3,col4
)
group by 子句后跟的字段就是你用来判断重复的条件,如只有col1,那么只要col1字段内容相同即表示记录相同。2,
select identity(int,1,1) as id,* into #temp from tabel
select * from #temp where id in (
select max(id) from #emp where having count(*)>1 group by col1,col2,col3...)
1、
?????????????????//
2、
select distinct f_a,f_b into #a from table1
delete from table1
insert into table1(f_a,f_b) select f_a,f_b from #a
DELETE FROM TB_A WHERE ID
NOT IN(SELECT MIN(ID) ID FROM TB_A GROUP BY F_A)alert table tb_a DROP COLUMN id
select (select sum(1) from 表 where f_d=aa.f_d and f_a<=aa.f_a) f_a,* from 表2、
alter table tb_a add newfield int identity(1,1)
delete tb_a where newfield not in( select min(newfield) from 表 group by f_a)
alter table tb_a drop column newfield