请问,一个排序问题!

aivii 2004-07-05 11:49:31
下面的语句,我已经排好序了(这是我在ACCESS中调试的,可能与SQL有出入):

select * from product where int(lb_id)=int("&lbid&") and ltrim(rtrim(key5))<>'' order by int(right(ltrim(rtrim(key5)),len(key5)-1))

但我想在此基础上,找出记录id(自增量)号为:100的下面三条记录,
请问大侠们,得如何写啊?谢谢!
...全文
93 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
aivii 2004-07-05
  • 打赏
  • 举报
回复
可能没懂我的意思,
我是想能通过一句SQL语句实现取ID为100的下面三样记录,

select * from product where int(lb_id)=int("&lbid&") and ltrim(rtrim(key5))<>'' order by int(right(ltrim(rtrim(key5)),len(key5)-1))
的基础,
也就是融为成一条语句,达到此目的,还请指点!
谢谢!
victorycyz 2004-07-05
  • 打赏
  • 举报
回复
select top 3 *
from product
where int(lb_id)=int("&lbid&") and ltrim(rtrim(key5))<>'' and id>100
order by id
CSDMN 2004-07-05
  • 打赏
  • 举报
回复
top 3
?
不是很明白楼主要什么
梅青松 2004-07-05
  • 打赏
  • 举报
回复
select * from product where int(lb_id)=int("&lbid&") and ltrim(rtrim(key5))<>'' order by int(right(ltrim(rtrim(key5)),len(key5)-1)) and rownum < 4 and id > 100
huwgao 2004-07-05
  • 打赏
  • 举报
回复
select top 3 *
from product
where int(lb_id)=int("&lbid&")
and ltrim(rtrim(key5))<>''
and int(right(ltrim(rtrim(key5)),len(key5)-1))>
(select int(right(ltrim(rtrim(key5)),len(key5)-1))
from product
where id=100)
order by int(right(ltrim(rtrim(key5)),len(key5)-1))
futulove 2004-07-05
  • 打赏
  • 举报
回复
自增号为101,102,103的吗
id=不就可以了吗

34,590

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧