sql 去除相同行

[复制链接]
查看11 | 回复3 | 2009-6-26 11:32:16 | 显示全部楼层 |阅读模式
表中两条记录 三个列列1 ,列2,列3 列1中 有重复行的,列2是录入时间,列3即id(唯一列)
查询表怎么把重复记录变成一条,而且那一条记录是最早录入的?
各位大虾帮帮忙咯
麻烦详细给个例子,谢谢

回复

使用道具 举报

千问 | 2009-6-26 11:32:16 | 显示全部楼层
select * from table1 twhere 列3=(select top 1 列3 from table1 where 列1=t.列1order by 列2 asc)--...
回复

使用道具 举报

千问 | 2009-6-26 11:32:16 | 显示全部楼层
selectdistinct(列一) from Table order by 列二 asc...
回复

使用道具 举报

千问 | 2009-6-26 11:32:16 | 显示全部楼层
delete from 表 t whereid not in (select top 1 id from 表 where t.列1=列1 order by 列2 asc)...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行