Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2015
    Posts
    1

    Unanswered: Excluding from results based on criteria - how to?

    I have an issue whereby I need to measure the number of people who had membership at any one time. So in the scenario, I need to know how many people have a full membership at a point in time (dotted line). In this instance, I want to ensure that Person B is only counted once instead of twice however the only way I can think of doing it is counting the number of start dates with no end date at a point in time. This however currently gives me a result of 3 instead of 2. How can I avoid Person B being counted?
    Click image for larger version. 

Name:	Member.jpg 
Views:	3 
Size:	57.2 KB 
ID:	16560
    Does this make sense? Whats the best way in Postgres to calculate this?

  2. #2
    Join Date
    Nov 2015
    Posts
    3
    If these people have distinct identities and each enrolment has an effective start and end date then you can use something like:

    select count(distinct id) from enrolments where now() between start_date and end_date;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •