求一SQL語句 有一個表t_customer,欄位code為Varchar(20),name為Varchar(40),Code為主鍵欄位,寫一條SQL語句刪除name相同但code不同且code不是相同name對應的最大值的記錄。(限一條SQL語句) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 delete a from table1 a where Code not in(select max(Code) from table1 where Name=a.name) delete t from 表 t where exists(select 1 from 表 where name=t.name and Code>t.Code) 其它方法參照http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html delete a from t_customer a where exists(select 1 from t_customer where Name=a.Name and code>a.code) delete t_customerwhere exists (select 1 from t_customer where name=t_customer.name and code<t_customer.code) delete a from t_customer a where code not in (select max(code) from t_customer where Name=a.Name) [code=SQL] delete t_customer aa where not exists(select 1 from t_customer where name = aa.name and code > aa.code ) [/SQL] 今天发现一个很奇怪的问题,是关于JOIN的 SQL SERVER 2K用户导出和导入 exec和execute有没区别? 一个查询语句怎么这么难写:( access数据库向sqlserver导数据的问题 我想写一个公交车查询库,以最快的查找速度做出发点,怎样的结构才算最好? SET XACT_ABORT ON不回滚RAISERROR的问题 关于时间的问题(sqlserver) 存储过程并发访问造成脏数据求解 如何极大提高sql server的性能 重建索引时,提示出错 求一个sql语句.
delete a from table1 a where Code not in(select max(Code) from table1 where Name=a.name)
where exists (select 1 from t_customer where name=t_customer.name and code<t_customer.code)