select id=identity(int,1,1),* into #t from dic_itemDetailtruncate table dic_itemDetailinsert into dic_itemDetail(mxmc,xx,xxx,...)
select a.mxmc,a.xx,a.xxx,...
from #t a
inner join (select mxmc,max(id) as id from dic_itemDetail group by mxmc) b
on a.id=b.id
select a.mxmc,a.xx,a.xxx,...
from #t a
inner join (select mxmc,max(id) as id from dic_itemDetail group by mxmc) b
on a.id=b.id
解决方案 »
- Eclipse 调用存储过程
- 问一个SQL语句怎么写,谢谢啦!
- 多表查询触发器的问题
- 要主表中增加一个ID,其他表中相应增加一个ID应该怎么来做?
- 为什么我得MSSQL2000数据库用本地服务器名可以连接数据库,用IP地址却不能连接数据库了呢???
- 管理大数据量表的方法
- 同样的函数,在sql2000和sql7.0里,居然不同。求助高手解答。
- 指定的服务并未以已安装的服务存在
- SQL Server 2000 中如何将数据库从一个恢复模型切换到另一个恢复模型
- 如何使Insert trigger 不影响 Insert ?
- select语句,关于记录合并的问题(急,求助)
- sql2000 bug??? 有关变量赋值问题
select a.mxbm,a.mxmc,a.xmflbm,a.gg,a.dw,a.pycode,a.wbcode,a.sfsy
from #t a
inner join (select mxmc,max(id) as id from #t group by mxmc) b
on a.id=b.id
一开始说ID列名无效,重新小改了一下就OK了,不过还是要谢谢楼上的,小生有礼了