Reputation: 343
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?
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
:
SELECT app FROM table WHERE timestamp>=333 AND NOT timestamp<333 GROUP BY app;
Any idea how can I perform that query?
Upvotes: 0
Views: 46
Reputation: 1270583
Use conditional aggregation:
SELECT app
FROM table t
GROUP BY app
HAVING MIN(timestamp) >= 333 ;
Upvotes: 2