📜  postgresql 过滤器开启 - SQL 代码示例

📅  最后修改于: 2022-03-11 15:05:36.333000             🧑  作者: Mango

代码示例1
SELECT COUNT(*) AS [column_name],
COUNT(*) FILTER (WHERE {column_name}{comparison_operator}{VALUE} ) 
   AS [column_name]
FROM TABLE_NAME;
# e.g. 
SELECT COUNT(*) AS no_filter,
COUNT(*) FILTER (WHERE id < 6 ) AS with_filter
FROM employee;