Published on March 21, 2021.
Last November, I shared a few queries that make use of NetSuite's LoginAudit table. I showed how you can query that table to analyze failed login attempts, determine the most recent login for a user, and determine when a role was last used.
This past week I used the LoginAudit table to help a client with a similar problem. They wanted to determine what users, if any, have access to their account but have not logged in within the past 90 days. In this post, I'll walk you through that query.
We'll start with a query that returns all active employees that have access to the account.
SELECT Employee.LastName, Employee.FirstName FROM Employee.Employee WHERE ( Employee.GiveAccess = 'T' ) AND ( Employee.IsInactive = 'F' ) ORDER BY Employee.LastName, Employee.FirstName
We'll also create a query that returns all user's that have ever logged into the account.
SELECT DISTINCT LoginAudit.User FROM LoginAudit
Next, we adjust that query so that only users that have logged in within the past 90 days are included. I covered SuiteQL's support for dates, including date arithmetic, in this post.
SELECT DISTINCT LoginAudit.User FROM LoginAudit WHERE ( LoginAudit.Date >= ( SYSDATE - 90 ) )
All that's left to do is combine the two queries. We'll use the second query as a subquery, along with a NOT IN clause, to filter out the employees that have logged in.
SELECT Employee.LastName, Employee.FirstName FROM Employee WHERE ( Employee.GiveAccess = 'T' ) AND ( Employee.IsInactive = 'F' ) AND ( Employee.ID NOT IN ( SELECT DISTINCT LoginAudit.User FROM LoginAudit WHERE ( LoginAudit.Date >= ( SYSDATE - 90 ) ) ) ) ORDER BY Employee.LastName, Employee.FirstName
And there you have it. The query will return a list of all active employees, that have been granted access to the account, but have not logged in within the past 90 days.
Hello, I’m Tim Dietrich. I design and build custom software for businesses running on NetSuite — from mobile apps and Web portals to Web APIs and integrations.
I’ve created several widely used open-source solutions for the NetSuite community, including the SuiteQL Query Tool and SuiteAPI, which help developers and businesses get more out of their systems.
I’m also the founder of SuiteStep, a NetSuite development studio focused on pushing the boundaries of what’s possible on the platform. Through SuiteStep, I deliver custom software and AI-driven solutions that make NetSuite more powerful, accessible, and future-ready.
Copyright © 2025 Tim Dietrich.