请sql 高手帮助。。。。。 图片如上:我的问题是 我首先根据 pono分组 , 其次是 取分组之后每组的第一条数据,等高手 帮助。谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 select *from (select *,rn = row_number() over (partition by pono order by id) from tb)awhere rn = 1 select *from tb twhere not exists (select * from tb where pono = t.pono and id > t.id) /** *前边都是取pono分组id最小的那个 */ select * from tb a id in(select top 1 id from tb where pono=a.id) 二楼的高手 能解释下什么意思吗?我用的sql 2000 提示: 'row_number' 不是可以识别的 函数名。 /** *你的SQL是2000版本,用下边那个吧!2000没有这个内置函数。 */ 太谢谢 AcHerat 了 ,同时也谢谢 ssp2009谢谢!!!!!! FULL JOIN ON 1=1是什么意思 求一SQL語句 如何利用动态拼接的SQL语句的执行结果 如何加载数据库 新手问题:SQL Server 2000数据库表中转存Accecc文件 如何查看数据库的所有执行sql语句的记录 使用Select查询,出现内存溢出错误。请各位指点! SQL Server 中多行多列连接成为单行多列 怎样把一个表中的一列装入到另一个表中,两个表的主键相同,按主键对号入座 两个表格中条件查询? 统计指定的几张表行数的SQL语句怎么写? 如何书写?
select *
from (select *,rn = row_number() over (partition by pono order by id) from tb)a
where rn = 1
select *
from tb t
where not exists (select * from tb where pono = t.pono and id > t.id)
/**
*前边都是取pono分组id最小的那个
*/
select * from tb a id in(select top 1 id from tb where pono=a.id)
我用的sql 2000 提示: 'row_number' 不是可以识别的 函数名。
/**
*你的SQL是2000版本,用下边那个吧!2000没有这个内置函数。
*/