oracle中having的使用

在oracle中where关键字是无法和聚合函数一起使用的,having可以让我们筛选分组后的各组数据。

用法:

SELECT column_name, aggregate_function(column_name)
FROM table_name
WHERE column_name operator value
GROUP BY column_name
HAVING aggregate_function(column_name) operator value;

例子:

SELECT
  count_date,
  sum(count_data) count_data
from TB_COUNT_DATA
GROUP BY count_date
HAVING SUM(count_data) > 200;

posted @ 2017-04-11 14:12  迷茫于红尘  阅读(2896)  评论(0编辑  收藏  举报