求一SQL语名 select a.* from 表 a where not exists(select 1 from 表 where xno=a.xno and id>a.id) 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 --楼主列出的结果是不是有错误?select id=max(id),xno from yourtable group by xno--result id xno 3 2 4 3 wzh1215(懒猫) --楼主列出的结果是不是有错误?------------------大哥,谢谢你的回答,我的结果没有错误,我是在写程序的过程中,如果,在第3组中,有两个人的评审级别都是4,那么在这两个人的“待办事宜”都要出现跟自已相关的一条记录!不知大哥出没有搞清楚我的意思????? select a.id,a.xnofrom 表名 a inner join (select max(id) as max_id,xno from 表名 group by xno ) b on a.id=b.max_id and a.xno=b.xnoorder by a.id create table #TP ( id int null , xno int null )insert #TP ( id , xno ) values ( 1 , 2 )insert #TP ( id , xno ) values ( 3 , 2 )insert #TP ( id , xno ) values ( 2 , 2 )insert #TP ( id , xno ) values ( 1 , 3 )insert #TP ( id , xno ) values ( 2 , 3 )insert #TP ( id , xno ) values ( 3 , 3 )insert #TP ( id , xno ) values ( 4 , 3 )insert #TP ( id , xno ) values ( 4 , 3 )select a.id,a.xnofrom #TP a inner join (select max(id) as max_id,xno from #TP group by xno ) b on a.id=b.max_id and a.xno=b.xnoorder by a.iddrop table #TP 配置 SQL2005 群集实现容错? 请问怎样用一条sql实现 请问建立索引和约束有什么区别? 求助高手,关于在sql2000中批量导入xml文档的问题 sql2008数据库关系图找不到指定的模块 只有一个数据库的备份文件,怎么恢复到新的数据库服务器中(不是原来的服务器) text 请问这个SQL语句该怎么写?在线等 求救: 存储过程的问题,(存储过程中使用了游标)。查询分析器执行正常; VC下调用报错: 函数序列错误 . 有关修改表结构的问题 关于SQL2000的统计功能 help me: sql7.0能否打sp3补丁,补丁哪里有下载?
select id=max(id),xno from yourtable group by xno
--result
id xno
3 2
4 3
--楼主列出的结果是不是有错误?
------------------大哥,谢谢你的回答,
我的结果没有错误,我是在写程序的过程中,
如果,在第3组中,有两个人的评审级别都是4,
那么在这两个人的“待办事宜”都要出现跟自已相关的一条记录!
不知大哥出没有搞清楚我的意思?????
from 表名 a inner join
(select max(id) as max_id,xno from 表名 group by xno ) b on a.id=b.max_id and a.xno=b.xno
order by a.id
create table #TP ( id int null , xno int null )insert #TP ( id , xno ) values ( 1 , 2 )
insert #TP ( id , xno ) values ( 3 , 2 )
insert #TP ( id , xno ) values ( 2 , 2 )
insert #TP ( id , xno ) values ( 1 , 3 )
insert #TP ( id , xno ) values ( 2 , 3 )
insert #TP ( id , xno ) values ( 3 , 3 )
insert #TP ( id , xno ) values ( 4 , 3 )
insert #TP ( id , xno ) values ( 4 , 3 )select a.id,a.xno
from #TP a inner join
(select max(id) as max_id,xno from #TP group by xno ) b on a.id=b.max_id and a.xno=b.xno
order by a.iddrop table #TP