如何得到Select结果集中某一行中的数据???
如何得到Select结果集中某一行中的数据???
楼主gjpfly(魔术师)2002-11-07 12:47:01 在 MS-SQL Server / 疑难问题 提问 For sample,
select * from item
would produce 100 rows. but I want to get the result of row 8. I know it can be done by cursor or looping. but there is any direct method ?
what I thought is like:
select * from item where rowcount = 8.
but sybase 10.9 not support rowcount. 问题点数:20、回复次数:9Top
1 楼chump(木人)回复于 2002-11-07 12:55:29 得分 0
好象没有办法!oracle中有rownum,SQL中没有啊!Top
2 楼Drate(小虫(好好学习,天天向上))回复于 2002-11-07 12:57:45 得分 0
除非在编程语言中,将结果集选择到客户端,然后再用定位函数,得到这条记录Top
3 楼sky_blue(蓝天2006)回复于 2002-11-07 12:59:14 得分 0
select identity(int,1,1)x,* into #tmp from item
select * from #tmp where x=8
没办法,只能这么做,SQLSERVER中不支持rownumTop
4 楼chenun(chenun)回复于 2002-11-07 14:20:25 得分 0
select top n * from item
-- n 为行数Top
5 楼lxinjun(lxj)回复于 2002-11-07 14:55:00 得分 10
ID为主见
SELECT TOP 1 FROM (SELECT TOP N FROM TABLE ORDER BY ID DESC)
Top
6 楼LaoZheng(阿明)回复于 2002-11-07 15:42:45 得分 0
upTop
7 楼mylovexs(不了塵)回复于 2002-11-07 16:31:27 得分 0
使用游標Top
8 楼enewren(*乡下的程序员*)回复于 2002-11-07 20:22:12 得分 0
select top n * from tablename
这是得到前n 条记录呀!!我今天才用过的,如何得到第n条记录????Top
9 楼jery_lee(U2-G2000)回复于 2002-11-07 21:03:32 得分 10
Declare cur Cursor
Declare @col1 integer
@col2 integer
for Select col1,col2
From Tablename
Open cur
Fetch cur ABSOLUTE n into @col1,@col2Top
-
相关文章
2秒记住本站域名
玩过泡泡龙吗?Readygo?Go! 再加上.Com.Cn的后缀,那就是大名小顶的readygo.com.cn
