我想问一下,如果使用aqua data studio数据为空时如何计算日期行。
例如
select
convert(varchar(10),dateclosed,103)
from customer
where dateclosed = '(null)'
no. dateclosed count(dateclosed)
1 1/1/2001 2
2. 1/1/2001
3. 2/1/2001 1
4. 3/1/2001 1
5. (null) 4
6. (null)
8. (null)
9. (null)
10. 5/1/2001 3
11. 5/1/2001
12. 5/1/2001
13. 6/1/2001 1
答案 0 :(得分:2)
聚合函数(COUNT(*)
除外)忽略NULL值,因此您需要:
COUNT(*)
(而不是COUNT(expression)
)将所有NULL值转换为某个特征日期:
SELECT ISNULL(dateclosed, '1900-01-01'), count(ISNULL(dateclosed, '1900-01-01'))
FROM customer
GROUP BY ISNULL(dateclosed, '1900-01-01')