Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8727075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:22:22+00:00 2026-06-13T08:22:22+00:00

The following code is probably self explanatory Lists number of active subscribers 1st of

  • 0

The following code is probably self explanatory

Lists number of active subscribers 1st of june

select 
    count(subscribers) as activeSubscribers 
from subscriberlist sub 
where 
    to_date('2012-06', 'yyyy-mm') 
        between sub.firstDayOfSubscription and sub.lastDayOfSubscription

But if I want to get the number of subscribers in the beginning of every month the past year, what could I do (besides changing the date in the query and repeating).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T08:22:23+00:00Added an answer on June 13, 2026 at 8:22 am

    You can generate a list of months as follows:

    SELECT add_months (trunc (to_date('01/01/2012','MM/DD/YYYY'), 'MM'), 1*LEVEL -1) FirstDay
            FROM Dual
         CONNECT BY LEVEL <= MONTHS_BETWEEN(to_date('12/31/2012','MM/DD/YYYY'), to_date('01/01/2012','MM/DD/YYYY')) + 1
           ORDER BY FirstDay
    

    This would give you the following output:

    FIRSTDAY
    --------
    January, 01 2012 00:00:00+0000
    February, 01 2012 00:00:00+0000
    March, 01 2012 00:00:00+0000
    April, 01 2012 00:00:00+0000
    May, 01 2012 00:00:00+0000
    June, 01 2012 00:00:00+0000
    July, 01 2012 00:00:00+0000
    August, 01 2012 00:00:00+0000
    September, 01 2012 00:00:00+0000
    October, 01 2012 00:00:00+0000
    November, 01 2012 00:00:00+0000
    December, 01 2012 00:00:00+0000
    

    You can then include that query as an inline view as follows:

    SELECT months.FirstDay,
           (SELECT count(subscribers)
              FROM subscriberlist sub
             WHERE months.FirstDay BETWEEN sub.firstDayOfSubscription AND sub.lastDayOfSubscription
           ) AS activeSubscribers
    FROM (SELECT add_months(trunc (to_date('01/01/2012','MM/DD/YYYY'), 'MM'), 1*LEVEL -1) FirstDay
            FROM Dual
         CONNECT BY LEVEL <= MONTHS_BETWEEN(to_date('12/31/2012','MM/DD/YYYY'), to_date('01/01/2012','MM/DD/YYYY')) + 1
           ORDER BY FirstDay) Months
    

    I’d probably wrap this in a sproc that accepts @startDate and @endDate parameters to define the date range you’re interested, but I followed your syntax with the date range being defined with strings.

    I was playing with this using this SqlFiddle

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting an error with the following bit of code. It is probably
There's probably a silly error in my code. I have defined the following variables:
The following code was taken from the ASP.NET page class (using Reflector): Public Custom
Recently I've found my self to implement code following a pattern like: public class
Following is sample code, aim is just to merges text files from give folder
I have the following code: class A(object): def __init__(self): self.name = A super(A, self).__init__()
The following code is taken from much larger code but I believe that this
Given the following code snippet from inside a method; NSBezierPath * tempPath = [NSBezierPath
Following code produces a nested array as a result for keys containing three items:
Following code takes like 2500 milliseconds on an i7-*3.4 GHz windows-7 64-bit computer to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.