[英]Query only elements which meets criteria
Let's say I have the following table: 假设我有下表:
id | packageName | app | timestamp
------------------------------------
1 | io.kodular... | A | 111
2 | io.kodular... | B | 222
3 | io.kodular... | A | 444
4 | io.kodular... | C | 555
How can I select elements grouped by app
that have a timestamp higher than 333
, but they don't have any record lower than that number? 我该如何选择按
app
分组的时间戳大于333
元素,但没有低于该数字的记录?
I need to get only app C
, as app A
has a lower timestamp record than 333. I have tried the following query, but it returns both app A
and app C
: 我只需要获取
app C
,因为app A
的时间戳记录比333低。我尝试了以下查询,但它同时返回了app A
和app C
:
SELECT app FROM table WHERE timestamp>=333 AND NOT timestamp<333 GROUP BY app;
Any idea how can I perform that query? 知道如何执行该查询吗?
Use conditional aggregation: 使用条件聚合:
SELECT app
FROM table t
GROUP BY app
HAVING MIN(timestamp) >= 333 ;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.