聚合函数对NULL统计

Table

  ID Amount Number
  1 28.26 NULL
  2 NULL NULL
  3 NULL NULL

SQL

  SELECT SUM(Amount),SUM(Number),COUNT(Amount),COUNT(Number),COUNT(1)
  FROM Test

  SELECT SUM(Amount),SUM(Number),COUNT(Amount),COUNT(Number),COUNT(1)
  FROM Test
  WHERE ID = -1

Data

  28.26 NULL 1 0 3

  NULL NULL 0 0 0

posted @ 2017-12-01 10:42  平小宅  阅读(149)  评论(0编辑  收藏  举报