如何按照价格排序

hhyhappy 2008-03-24 10:56:49
有两个表,其中一个表hotelinfo代表公寓信息,如公寓介绍、周围标志物、地址等,表hotelrooms代表公寓客房信息,dayrent代表房

价,我现在想要做的是把公寓中所有价格高于600元的酒店显示出来,我想按照价格升序来排,我这样写,只能把符合条件的显示出来,

但是不能按照价格升序来排,请各位大虾帮忙啊!

strSQL="select * from hotelinfo a where id in (select hotelid from hotelrooms b where dayrent > 600 group by hotelid)

order by id desc"
...全文
287 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
liuyann 2008-03-24
  • 打赏
  • 举报
回复


不好意思,贴错了,应该是order by
strSQL="select a.* from hotelinfo a inner join (select hotelid,min(dayrent) as mindayrent from hotelrooms where dayrent>600 group by hotelid) b on a.id=b.hotelid order by b.mindayrent"

== 思想重于技巧 ==
liuyann 2008-03-24
  • 打赏
  • 举报
回复

strSQL="select a.* from hotelinfo a inner join (select hotelid,min(dayrent) as mindayrent from hotelrooms where dayrent>600 group by hotelid) b on a.id=b.hotelid where b.mindayrent"
== 思想重于技巧 ==
myvicy 2008-03-24
  • 打赏
  • 举报
回复
strSQL="select a.* from hotelinfo a,(select hotelid,dayrent from hotelrooms b where dayrent > 600 group by hotelid) b where a.id=b.hotelid order by b.dayrent desc"
里面少选了一列.
hhyhappy 2008-03-24
  • 打赏
  • 举报
回复
我先要找出同一个hotelid中的最低价,即 min(dayrent),然后再按照每个公寓中的最低价来排序!
hhyhappy 2008-03-24
  • 打赏
  • 举报
回复
to :myvicy

按照你说的,提示:

[Microsoft][ODBC SQL Server Driver][SQL Server]列名 'dayrent' 无效。

我说明一下,dayrent在hotelrooms 表中
myvicy 2008-03-24
  • 打赏
  • 举报
回复
strSQL="select a.* from hotelinfo a,(select hotelid from hotelrooms b where dayrent > 600 group by hotelid) b where a.id=b.hotelid order by b.dayrent desc"
kelph 2008-03-24
  • 打赏
  • 举报
回复
strSQL="select * from hotelinfo a where id in (select hotelid from hotelrooms b where dayrent > 600 group by hotelid) order by dayrent"

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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