I have two tables that contain data from different temperature sensors:
Table1
_TimeStamp Temperature
2009-12-20 11:59:56.2 10.1
2009-12-20 11:59:56.3 10.2
2009-12-20 11:59:56.4 11.0
2009-12-20 11:59:56.5 Null
Table2
_TimeStamp Temperature
2009-12-20 11:59:56.2 10.5
2009-12-20 11:59:56.5 9.8
2009-12-20 11:59:56.7 12.0
2009-12-20 11:59:56.9 10.0
I want to count the number of records for which either one of the two temperature sensors made a non-null measurement. For the example above, the count is 6, though there are actually 864000 or so records in each table.
I know the following SQL Server query is wrong, but could you help correct it?
(SELECT DISTINCT COUNT(_TimeStamp) FROM Table1) UNION (SELECT DISTINCT COUNT(_TimeStamp) FROM Table2)