Reputation: 1
I have output like as:
+-----------+------------+--------------+
| client_id | date | spends |
+-----------+------------+--------------+
| 57 | 2014-09-28 | 39576.384391 |
| 57 | 2014-10-05 | 22664.382575 |
+-----------+------------+--------------+
I need such row that if previous week spends is null and current week having spend.
Upvotes: 0
Views: 159
Reputation: 1269493
Is this what you need?
select t.*
from table t
where spend is not null and
exists (select 1
from table t2
where t2.client_id = t.client and
t2.spends is null and
t2.date = t.date - interval 7 days
);
Upvotes: 1