聚集查询
最近更新时间: 2025-02-18 16:02:00
- 统计记录数。
postgres=# select count(1) from tbase;
count
-------
3
(1 row)
- 统计不重复值的记录表。
postgres=# select count(distinct id) from tbase;
count
-------
2
(1 row)
- 求和。
postgres=# select sum(id) from tbase;
sum
-----
4
(1 row)
- 求最大值。
postgres=# select max(id) from tbase;
max
-----
2
(1 row)
- 求最小值。
postgres=# select min(id) from tbase;
min
-----
1
(1 row)
- 求平均值。
postgres=# select avg(id) from tbase;
avg
--------------------
1.3333333333333333
(1 row)