Sqlite 返回null的计数函数
我对count函数有一个问题,其中count函数返回空值 我有四张桌子Sqlite 返回null的计数函数,sqlite,Sqlite,我对count函数有一个问题,其中count函数返回空值 我有四张桌子 控件(ruid、ratc\u id、原始值、值、最小值、最大值、转换id、单位、监视器、更改) 事件(ruid、事件id、最小值、最大值、当前状态、以前状态) 事件日志(ruid、事件id、原始值、时间戳) 监视器 我对计数函数有问题。这是我代码的一部分 create temp table Testing_table as select event_log.[ruid] as ruid, event_log.[raw_va
create temp table Testing_table as
select event_log.[ruid] as ruid, event_log.[raw_value] as raw_value, event_log.[event_id] as event_id, event_log.[timestamp] as timestamp, count ('Test_ID') as 'Test_ID', null as 'Test Result'
from event_log
JOIN controls
on event_log.[ruid] = controls.[ruid]
and event_log.[raw_value] = controls.[raw_value]
UNION
select
ruid, raw_value, event_id, timestamp, null as 'Test_ID',
CASE
when raw_value = 0.9343453535635 then 'Pass'
when raw_value = 0.04583743847 then 'Pass'
when raw_value = 0.563363656757 then 'Pass'
when raw_value = 0.6666666666 then 'Pass'
when raw_value = 0.65757447777 then 'Pass'
when raw_value = 0.9267482727372 then 'Pass'
when raw_value = 0.2323239945454 then 'Pass'
when raw_value = 0.9732746367437 then 'Pass'
when raw_value = 0.0222222222222 then 'Pass'
when raw_value = 0.5656857676747 then 'Pass'
when raw_value = 0.6546456363563 then 'Pass'
when raw_value = 0.0348343874738 then 'Pass'
when raw_value = 0.9457458745737 then 'Pass'
when raw_value = 0.543452434345 then 'Pass'
when raw_value = 0.9836438454522 then 'Pass'
when raw_value = 0.2546456745635 then 'Pass'
when raw_value = 0.0456474635353 then 'Pass'
when raw_value = 0.9454545454256 then 'Pass'
when raw_value = 0.0456474635353 then 'Pass'
when raw_value = 0.4536465665635 then 'Pass'
when raw_value = 0.4536465665635 then 'Pass'
when raw_value = 0.4545465752726 then 'Pass'
when ruid = 2 then 'Not in events_log'
when ruid = 4 then 'Not in events_log'
else 'Failed'
end
as 'Test Result'
from event_log;
select * from Testing_table;
以下是查询结果:
ruid raw_value event_id timestamp Test_ID Test Result
1 0.04583743847 1 2014-03-06 13:33:52.187 <null> Pass
1 0.563363656757 1 2014-03-06 13:33:52.187 <null> Pass
1 0.9267482727372 1 2014-03-06 13:33:52.187 <null> Pass
3 0.0222222222222 2 2014-03-06 13:33:52.187 <null> Pass
3 0.0348343874738 2 2014-03-06 13:33:52.187 <null> Pass
3 0.2323239945454 2 2014-03-06 13:33:52.187 <null> Pass
3 0.5656857676747 2 2014-03-06 13:33:52.187 <null> Pass
3 0.9457458745737 2 2014-03-06 13:33:52.187 <null> Pass
3 0.9457458745737 2 2014-03-06 13:33:52.187 2 <null>
3 0.9732746367437 2 2014-03-06 13:33:52.187 <null> Pass
5 0.0456474635353 3 2014-03-06 13:33:52.187 <null> Pass
5 0.2546456745635 3 2014-03-06 13:33:52.187 <null> Pass
5 0.4536465665635 3 2014-03-06 13:33:52.187 <null> Pass
5 0.9454545454256 3 2014-03-06 13:33:52.187 <null> Pass
5 0.9836438454522 3 2014-03-06 13:33:52.187 <null> Pass
ruid原始值事件id时间戳测试id测试结果
1 0.0458374384712014-03-0613:33:52.187通过
1 0.563363656757 1 2014-03-06 13:33:52.187通过
1 0.9267482727372 1 2014-03-06 13:33:52.187通过
3 0.022222 2014-03-06 13:33:52.187通过
3 0.0348343874738 2 2014-03-06 13:33:52.187通过
3 0.23233949454 2 2014-03-06 13:33:52.187通过
3 0.5656857674722014-03-0613:33:52.187通过
30.945745874573722014-03-0613:33:52.187通过
3 0.9457458745737 2 2014-03-06 13:33:52.187 2
30.973274636743722014-03-0613:33:52.187通过
5 0.0456474635353 2014-03-06 13:33:52.187通过
5 0.2546456745635 3 2014-03-06 13:33:52.187通过
5 0.4536465665635 3 2014-03-06 13:33:52.187通过
5 0.9454256 3 2014-03-06 13:33:52.187通过
5 0.9836438454522 3 2014-03-06 13:33:52.187通过
如何使Test_ID列每行增加一个
希望这一切都有意义。COUNT永远不会返回NULL。因为在SELECT中显式写入NULL,所以得到NULL。好的,如何获得查询结果以生成所需的结果。我希望test_id以一步一步的方式递增,这样我就可以按照test_id对表进行排序,它应该如何确定哪个结果记录获得哪个test_id?我希望test_id列获得test id,但我不确定它将如何确定哪个结果将获得test id