create table #t
(
pkid int
)
insert #t select 1
insert #t select 1
insert #t select 2
insert #t select 3
insert #t select 3
insert #t select 4我想得到的结果是,但不能用2005的排名函数,因为我的是2000 :-(
1
1
3
4
4
6
解决方案 »
- 数据空值替换问题
- MySQL的的问题
- 有外键关系的表数据删除?
- vb6中Format(数值,"###,##0.######")可以输出像这样的格式,1,234,567.89 我用SQL自定义函数实现了,请高手来挑刺。
- SQL模糊查询求助
- 没有ID字段,所有字段都是char型,可以通过Order by 的方法按顺序查找记录,请问如果应该用什么SQL语句才能查询到数据库的前500条记录?
- 请教一个搜索查询问题?
- 数据分区后插入的数据未保存到目的文件里??
- SQL分类汇总问题
- MSSQL sa用户登录过几分钟后失效的问题,跪等解决!
- 一些有用的SQL Server语句和存储过程
- SQL Server 2005数据库中的Output子句
(
pkid int
)
insert #t select 1
insert #t select 1
insert #t select 2
insert #t select 3
insert #t select 3
insert #t select 4select pkid,
rnk=(select count(*) from #t where pkid<t.pkid)+1
from #t as tdrop table #t/*
pkid rnk
----------- -----------
1 1
1 1
2 3
3 4
3 4
4 6(6 row(s) affected)
*/
(
pkid int
)
insert #t select 1
insert #t select 1
insert #t select 2
insert #t select 3
insert #t select 3
insert #t select 4select pkid,
rnk=(select count(distinct pkid) from #t where pkid<t.pkid)+1
from #t as tdrop table #t/*
pkid rnk
----------- -----------
1 1
1 1
2 2
3 3
3 3
4 4(6 row(s) affected)
*/