【Python百日进阶-Web开发-Peewee】Day295 - 查询示例(四)聚合1

文章目录

    • 14.6 聚合
      • 14.6.1 计算设施数量 Count the number of facilities
      • 14.6.2 计算昂贵设施的数量 Count the number of expensive facilities
      • 14.6.3 计算每个成员提出的建议数量。Count the number of recommendations each member makes.
      • 14.6.4 列出每个设施预订的总空位 List the total slots booked per facility
      • 14.6.5 列出给定月份每个设施预订的总时隙 List the total slots booked per facility in a given month
      • 14.6.6 列出每个设施每月预订的总时隙 List the total slots booked per facility per month
      • 14.6.7 查找至少进行过一次预订的会员人数 Find the count of members who have made at least one booking
      • 14.6.8 列出预订超过 1000 个位置的设施 List facilities with more than 1000 slots booked
      • 14.6.9 找出每个设施的总收入 Find the total revenue of each facility
      • 14.6.10 查找总收入低于 1000 的设施 Find facilities with a total revenue less than 1000
      • 14.6.11 输出预订数量最多的设施 ID. Output the facility id that has the highest number of slots booked
      • 14.6.12 列出每个设施每月预订的总时段,第 2 部分 List the total slots booked per facility per month, part 2

14.6 聚合

http://docs.peewee-orm.com/en/latest/peewee/query_examples.html#aggregation
聚合是真正让您欣赏关系数据库系统强大功能的功能之一。它使您可以超越仅保留数据,进入提出真正有趣的问题的领域,这些问题可用于为决策制定提供信息。此类别详细介绍了聚合,使用标准分组以及更新的窗口函数。

14.6.1 计算设施数量 Count the number of facilities

对于我们第一次涉足聚合,我们将坚持一些简单的事情。我们想知道有多少设施存在——只需产生一个总数。

SELECT COUNT(facid) FROM facilities<

你可能感兴趣的:(Dash,python,前端,dash)