如何按照价格排序

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"
...全文
129 点赞 收藏 7
写回复
7 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
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"
回复
相关推荐
发帖
ASP
创建于2007-09-28

2.8w+

社区成员

ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
申请成为版主
帖子事件
创建了帖子
2008-03-24 10:56
社区公告
暂无公告