Jim Posted November 27, 2023 Share Posted November 27, 2023 I have been asked to return a count of users who have not logged requests within a given date range. I've had to go back to basics on the query just to test and I'm not getting any results on this at all? select h_user_id from h_sys_accounts WHERE h_user_id NOT IN (select h_fk_user_id from h_itsm_requests) If I choose the opposite and return a distinct list of users who have logged requests, the query works but not if I choose NOT IN. Am I missing something obvious here as there are definitely accounts that have not logged requests Link to comment Share on other sites More sharing options...
James Ainsworth Posted November 28, 2023 Share Posted November 28, 2023 Hi Jim, Thanks for your post. I believe that your query doesn't return anything because when using NOT IN, each result returns NULL and with a NULL value nothing gets displayed. Try this. SELECT h_user_id FROM h_sys_accounts WHERE NOT EXISTS ( SELECT NULL FROM h_itsm_requests WHERE h_user_id = h_fk_user_id ) 1 Link to comment Share on other sites More sharing options...
Jim Posted November 29, 2023 Author Share Posted November 29, 2023 Thank you that looks perfect, can add in the rest of my criteria now and start the measures. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now