我想比较一下目前(所有未来日期)可用的酒店房间总数与历史日期可用的房间总数。下面的查询将检索截至今天的可用房间数
SELECT date, sum(availability) FROM AVAILABILITY WHERE date = current_date
我要查找的输出类似于:日期,可用房间总数05/07, 10006/07, 110今天,90岁提前谢谢
2sbarzqh1#
你只是想 group by ?
group by
SELECT date, sum(availability) FROM AVAILABILITY WHERE date >= current_date GROUP BY date;
您似乎需要具有聚合的窗口函数:
SELECT date, SUM(SUM(availability)) OVER (date DESC) FROM AVAILABILITY WHERE date >= current_date GROUP BY date;
1条答案
按热度按时间2sbarzqh1#
你只是想
group by
?您似乎需要具有聚合的窗口函数: