Hi! If you're in Cloud you can see the Audit log by clicking on your avatar > Bitbucket settings > Audit log. You won't be able to filter so you'll see all the activity that happened into the account.
If you're using Bitbucket Server, you can get a different kind of audit. You can read more about it at Audit logging in Bitbucket Server.
Hope that helps!
Hi Vivuu, you can find some SQL examples in the article Query for inactive or idle users. You can find MySQL, Postgres and Oracle, Transact SQL (the variant that MSSQL uses) is not included but maybe you can work around the previous ones.
As for the query you're asking for, I'm afraid I'm not familiar with the variant of SQL that Microsoft uses. Hopefully some other user will be able to help you with that :)