Search for field 1 that that comes before field 0

Hello all, I have an InfludDB query question for ya, I have a meaurement called user_login. In this meaurement the field is status with either a zero or a one, with a tag of users. Here is an example:
| FIELD | TAG |
|---------------------------|
| status: 1 | user: bob |
| status: 1 | user: bob |
| status: 1 | user: bob |
| status: 0 | user: bob |
| status: 1 | user: bob |
| status: 1 | user: kim |
| status: 1 | user: kim |
| status: 1 | user: bob |
| status: 0 | user: bob |
| status: 1 | user: bob |
| status: 0 | user: kim |
| status: 1 | user: kim |
| status: 1 | user: kim |
| status: 0 | user: kim |
| status: 1 | user: kim |
| status: 1 | user: kim |
| status: 1 | user: bob |
| status: 1 | user: bob |

When a user requests a new web service, then status = 1 and tag will contain the user name. When a user logs out, a new entry is created with status = 0.

I am tring to find logged users where users 1 > then user’s last(0)

Somthing like
SELECT “user” FROM “user_login” where
(SELECT LAST(time) from “user_login” WHERE (status == 0) GROUP BY “user”) < time
AND status == 1
GROUP BY “user”
I know this is probubly a simple query but it is killing me. Thanks for any help you might be able to give.

– Ean Poe

@000devhelp,
Welcome and thank you for your question. Just so that we’re on the same page, can you share what you expect the output of your query to yield? Thanks!