postgresql-聚合函数增强功能

postgresql-聚合函数增强功能

按季度统计入职员工

sql 复制代码
select 
-- extract截取,按季度进行统计入职员工总数
extract(year from hire_date),
count(*) filter(where extract(quarter from hire_date) = 1) "第一季度",
count(*) filter(where extract(quarter from hire_date) = 2) "第二季度",
count(*) filter(where extract(quarter from hire_date) = 3) "第三季度",
count(*) filter(where extract(quarter from hire_date) = 4) "第四季度"
from employees e
-- 1表示按查询结果第一列进行分组
group by 1;
相关推荐
月光水岸New2 小时前
Ubuntu 中建的mysql数据库使用Navicat for MySQL连接不上
数据库·mysql·ubuntu
狄加山6752 小时前
数据库基础1
数据库
我爱松子鱼2 小时前
mysql之规则优化器RBO
数据库·mysql
chengooooooo2 小时前
苍穹外卖day8 地址上传 用户下单 订单支付
java·服务器·数据库
Rverdoser3 小时前
【SQL】多表查询案例
数据库·sql
Galeoto3 小时前
how to export a table in sqlite, and import into another
数据库·sqlite
人间打气筒(Ada)4 小时前
MySQL主从架构
服务器·数据库·mysql
leegong231114 小时前
学习PostgreSQL专家认证
数据库·学习·postgresql
喝醉酒的小白4 小时前
PostgreSQL:更新字段慢
数据库·postgresql
敲敲敲-敲代码4 小时前
【SQL实验】触发器
数据库·笔记·sql