为什么SQL百分比计算对于不等于零的内容返回零百分比?

时间:2015-03-27 16:06:09

标签: sql-server statistics

QUERY:

SELECT
  _column_ as segment,
  count(*) as count,
  (Count(_column_)* 100 / (Select Count(*) From _table_)) as percentage
FROM
  _table_
GROUP BY _column_
ORDER BY _column_

输出:

[{ segment: null,  count: 308,    percentage: 0 },
 { segment: 1,     count: 16346,  percentage: 40 },
 { segment: 2,     count: 13186,  percentage: 32 },
 { segment: 3,     count: 10309,  percentage: 25 }]

为什么此查询会为null段返回0%?

0 个答案:

没有答案