Incremental and decremental count based on a date

From: koimoi <s(dot)raddy(dot)89(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Incremental and decremental count based on a date
Date: 2018-02-20 21:11:54
Message-ID: 1519161114631-0.post@n3.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Name Start_date end_date
aaa 01/02/2017 05/03/2017
bbb 03/05/2017 07/07/2017
ccc 02/01/2017 10/09/2017
I want to write a query that calculates the number of people who exist in
the DB in a certain month/year.

Answer:

Jan 2017 1
Feb 2017 2
Mar 2017 3
Apr 2017 3
May 2017 2 (one person - aaa ,ended in May 2017)
Jun 2017 2
Jul 2017 1 (bbb ended in July 2017)
How do I write a PSQL query to get the desired output?

Thanks.

--
Sent from: http://www.postgresql-archive.org/PostgreSQL-novice-f2132464.html

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message David G. Johnston 2018-02-20 21:29:41 Re: Incremental and decremental count based on a date
Previous Message Stephen Froehlich 2018-02-20 19:30:23 RE: upgrade to version 10.2 question