我想在过去3天内进行一项条件测试。预期的结果是仅列出数学条件的客户的列表。条件是在最后3天内具有:diffsucces> = 3。我使用以下查询,但它不起作用,因为条件仅应用于最后一天。
select CollectionTime,DeviceName,RessourceNameMac,diffsucces
from CmSuccess
where CollectionTime > current_date - interval '3' day and RessourceNameMac NOT LIKE "%00%"
group by RessourceNameMac
having (diffsucces)>=3;
图片下方的示例: sample
通过查询,我有“EMA”和“STB”而不是“EMA”
样品 日期; RessourceNameMac; diffsucces 17/02/2017; STB; 2 17/02/2017; EMA; 6 18/02/2017; EMA; 10 18/02/2017; STB; 1 19/02/2017; STB; 4 19/02/2017; EMA; 5 20/02/2017; STB; 5 20/02/2017; EMA; 4
结果预期 日期; RessourceNameMac; diffsucces 20/02/2017; EMA; 4