zgfp.net
当前位置:首页 >> sql语句,分别删除每个A字段下B字段最大的记录,应... >>

sql语句,分别删除每个A字段下B字段最大的记录,应...

select min(a),b,c from A表 group by b,c 或者 select max(a),b,c from A表 group by b,c

这个应该是更新 update table1 set a = substring(a,1,charindex('B')-1) --截取B之前的值,将B之后的舍弃

select max(id) id,name from 表 group by name --如果表中还有其他字段要查出,那么 select * from 表 where id in (select max(id) from 表 group by name )

Select a.code,a.name,b.name2 from a left join (Select distinct name1, name2=(select name2+',' from b where name1=t.name1 for xml path('') ) from b as t) as b on a.name=b.name1 差不多就这个样子吧

SQL命令:SELECT * FROM 表名 where A=120 order by E desc 这样查询结果为: A 120 B 156 C 263 D 268 E 235 A 120 B 156 C 263 D 268 E 123 这样查询命令的意思就是说:查询表里面的“A”字段等于120的所以数据并且以“E”字段的大到小排列,你只需...

delete from A where (d,rowid) in (select d,max(rowid) from A group by d having count(*)>1); 如果d重复记录数大于2,则反复执行词句,一直到d无重复值为止。

若A里的a字段要等于B中的b字段就用1L的写法,若是包含就这么写 select * from A where exists (select 1 from B where A.a like '%'+B.b+'%')

你是要更新数据,还是增加数据: 增加数据: insert B(b) select a from A where ... 更新数据: update B set B.b = A.a from A where ...

delete a where id=111 delete c where eid in (select eid from b where cid=111) delete b where cid=111

网站首页 | 网站地图
All rights reserved Powered by www.zgfp.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com