Jump to content

Count users who have not logged requests


Jim

Recommended Posts

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

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
        )

 

  • Thanks 1
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...