【发布时间】:2019-11-19 06:11:49
【问题描述】:
感觉这应该是一件容易的事。如何获取不同列中日期不为空的单元格计数。
DROP TABLE #indebtedness
CREATE TABLE #indebtedness (call_case CHAR(10), date1 DATETIME, date2 DATETIME, date3 DATETIME)
INSERT #indebtedness VALUES ('Key1', '2019-10-30', '2019-11-30', null )
INSERT #indebtedness VALUES ('Key2', NULL , null , '2019-10-15')
INSERT #indebtedness VALUES ('Key3', '2019-11-11', '2019-10-29', '2019-10-30')
INSERT #indebtedness VALUES ('Key4', null , '2019-10-29', '2019-10-13')
我希望结果是:
call_case NOT NULL
Key1 2
Key2 1
Key3 3
Key4 2
【问题讨论】:
标签: sql sql-server tsql count sum