您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何计算5天的总价格(mysql)酒店预订系统

如何计算5天的总价格(mysql)酒店预订系统

这是查询

select sum(coalesce(prices.room_price , def.room_price) ) as TotalPrice
from (select strtodate('2013-01-07' , '%Y-%m-%d') as thedate union all
      select strtodate('2013-01-08' , '%Y-%m-%d') as thedate
     ) dates left outer join
     ts_room_prices prices
     on dates.thedate between prices.season_start and prices.season_end and
        dayname(dates.thedate) = prices.dayofweek join ts_room prices def
    on def.season_name = 'default' and
       def.hotel = <whatever the hotel is> and
       def.dayofweek = dayname(dates.thedate)

注意,sum()表达式要简单得多,现在星期几在联接中。我还添加获取认值的酒店条件-这也应该在其他查询中。

请记住,您必须将所有日期与组合在一起放入初始子查询union all

MySQL 2022/1/1 18:51:02 有467人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶