sql重复数据取最新的一条
@鞠裕3558:sql中如何取重复的数据取时间最近的一条? -
沃胃15880257099…… 既然数据都重复,就时间不同,那就取max(时间)就行了吧 select 重复数据的列名1,重复数据的列名2,....,max(时间列) from table group by 重复数据的列名1,重复数据的列名2,....
@鞠裕3558:SQL删除重复数据,保留最近修改的一条记录. -
沃胃15880257099…… //取到最近一条记录 select type,xtype from 表名 where type='P' and xtype='3' order by execTime desc limit 1; //拿到type和xtype两个值 type1 和 xtype1 delete from 表名 where type='P' and xtype='3' and type<>type1 and xtype<>xtype1; 这样就可...
@鞠裕3558:数据库里2条记录相同.我想取其中一个时间最新的SQL语句怎么写? -
沃胃15880257099…… 你的表里有没有字段是表示更新时间的呢? 如果没有, 那就没法. 如果有, 那就对更新时间进行排序取第一条.
@鞠裕3558:sql 重复只查询最近的一条数据 -
沃胃15880257099…… select a.* ,b.* from a,b, (select cust_pid,max(oper_time) as oper_time from b group by cust_pid) cwhere a.cust_pid=b.cust_pid and b.cust_pid=c.cust_pid and b.oper_tim...
@鞠裕3558:sql重复数据取最新的记录(不是一条) -
沃胃15880257099…… 您好,可以这样写 select a1.item,a1.price,a1.date from tab_a a1, (select item,max(date) as "rq" from tab_a group by item) a2 where a1.item = a2.item and a1.date = a2.rq;
@鞠裕3558:sql select 重复数据取最新记录 -
沃胃15880257099…… SELECT * FROM TableX WHERE ID IN ( -- 子查询,取每个人的最大ID SELECT Max(ID) -- 假定时间越晚,ID也越大 FROM TableX GROUP BY name )
@鞠裕3558:SQL 数据库中有很多相同数据,只需更新一条记录,怎么操作 -
沃胃15880257099…… 忘了是那个数据库,可以根据rownum来操作
@鞠裕3558:数据库如何只更新重复数据中的一条 -
沃胃15880257099…… 列完全重复时,SQL05以上版本用CTE.SQL2000用临时表和辅助列 如: T2: ID Name 1 Name 1 Name 2 Name2 alter table t add row int identity select * from t2 a where row=(select min(row) from t2 where ID=a.ID and Name=a.Name) update
@鞠裕3558:sqlserver 怎么根据表中三列去重复 然后取最新日期的那一条的值 -
沃胃15880257099…… 用JOIN 试试,将e列用一个子集做为条件,应该可以,BAIDU下JOIN的用法吧.
@鞠裕3558:求Sql语句字段的重复记录,保留一条记录 -
沃胃15880257099…… delete a from SA_CusUPrice a where not exists (select 1 from (select ccusccode,cinvcode,max(dstartdate) dstartdate from SA_CusUPrice group by ccusccode,cinvcode) b where a.ccusccode = b.ccusccode and a.cinvcode=b.cinvcode and a.dstartdate =b.dstartdate )
沃胃15880257099…… 既然数据都重复,就时间不同,那就取max(时间)就行了吧 select 重复数据的列名1,重复数据的列名2,....,max(时间列) from table group by 重复数据的列名1,重复数据的列名2,....
@鞠裕3558:SQL删除重复数据,保留最近修改的一条记录. -
沃胃15880257099…… //取到最近一条记录 select type,xtype from 表名 where type='P' and xtype='3' order by execTime desc limit 1; //拿到type和xtype两个值 type1 和 xtype1 delete from 表名 where type='P' and xtype='3' and type<>type1 and xtype<>xtype1; 这样就可...
@鞠裕3558:数据库里2条记录相同.我想取其中一个时间最新的SQL语句怎么写? -
沃胃15880257099…… 你的表里有没有字段是表示更新时间的呢? 如果没有, 那就没法. 如果有, 那就对更新时间进行排序取第一条.
@鞠裕3558:sql 重复只查询最近的一条数据 -
沃胃15880257099…… select a.* ,b.* from a,b, (select cust_pid,max(oper_time) as oper_time from b group by cust_pid) cwhere a.cust_pid=b.cust_pid and b.cust_pid=c.cust_pid and b.oper_tim...
@鞠裕3558:sql重复数据取最新的记录(不是一条) -
沃胃15880257099…… 您好,可以这样写 select a1.item,a1.price,a1.date from tab_a a1, (select item,max(date) as "rq" from tab_a group by item) a2 where a1.item = a2.item and a1.date = a2.rq;
@鞠裕3558:sql select 重复数据取最新记录 -
沃胃15880257099…… SELECT * FROM TableX WHERE ID IN ( -- 子查询,取每个人的最大ID SELECT Max(ID) -- 假定时间越晚,ID也越大 FROM TableX GROUP BY name )
@鞠裕3558:SQL 数据库中有很多相同数据,只需更新一条记录,怎么操作 -
沃胃15880257099…… 忘了是那个数据库,可以根据rownum来操作
@鞠裕3558:数据库如何只更新重复数据中的一条 -
沃胃15880257099…… 列完全重复时,SQL05以上版本用CTE.SQL2000用临时表和辅助列 如: T2: ID Name 1 Name 1 Name 2 Name2 alter table t add row int identity select * from t2 a where row=(select min(row) from t2 where ID=a.ID and Name=a.Name) update
@鞠裕3558:sqlserver 怎么根据表中三列去重复 然后取最新日期的那一条的值 -
沃胃15880257099…… 用JOIN 试试,将e列用一个子集做为条件,应该可以,BAIDU下JOIN的用法吧.
@鞠裕3558:求Sql语句字段的重复记录,保留一条记录 -
沃胃15880257099…… delete a from SA_CusUPrice a where not exists (select 1 from (select ccusccode,cinvcode,max(dstartdate) dstartdate from SA_CusUPrice group by ccusccode,cinvcode) b where a.ccusccode = b.ccusccode and a.cinvcode=b.cinvcode and a.dstartdate =b.dstartdate )