duankekan9269 2013-12-30 08:31
浏览 32

MySQL的每周价格

I have following table structure

id, startdate, hotelid, price

On front-end I am showing min and max price as $35 - $671 (per day) This is min and max price of the hotel per day. I can fetch the per day data based on GROUP BY hotelid and getting min/max price as below:

SELECT
    hotelid,
    MIN(price) AS `minprice`,
    MAX(price) AS `maxprice`
FROM
    hotel_price
WHERE
    startdate > NOW()
    AND
    price > 0
GROUP BY
    hotelid;

Now, customer wants to show per week price as min/max. But I am confused because I have data as per day basis in table, how should I calculate and show weekly SUM of price as min max? How we can do this in a mysql query?

  • 写回答

2条回答 默认 最新

  • duanhuhong5255 2013-12-30 08:36
    关注

    try in where

    WHERE price > 0 and startdate BETWEEN NOW() and DATE_SUB(NOW(), INTERVAL 7 DAY)
    
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!