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

  • Home
  • SEARCH
  • 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 9172389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:20:03+00:00 2026-06-17T16:20:03+00:00

Looking to get record counts for each month. However, several months has no records

  • 0

Looking to get record counts for each month. However, several months has no records therefore no row is returned. How can I get a count of 0 for that month?

select months, count(rowid) as counter from (
    select  to_char(date_entered, 'MM') as months
    from mydatatable
    where to_char(date_entered, 'yyyy') = '2011'
     )
group by months
order by months

Result:

Month    Count
01       32
03       12
04       11
06       10
07       222
08       32

Even tried playing with subq select 1,2,3,4,5,6,7,8,9,10,11,12 from dual and could not get it to work. No pivot capability yet… ;(

  • 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-17T16:20:05+00:00Added an answer on June 17, 2026 at 4:20 pm

    You’re probably better off storing the 01 to 12 in a table, but the general approach is to use a left join:

    Select
      m.Mo,
      Count(t.dateentered)
    From (
        Select '01' As Mo From Dual Union All
        Select '02' From Dual Union All
        Select '03' From Dual Union All
        Select '04' From Dual Union All
        Select '05' From Dual Union All
        Select '06' From Dual Union All
        Select '07' From Dual Union All
        Select '08' From Dual Union All
        Select '09' From Dual Union All
        Select '10' From Dual Union All
        Select '11' From Dual Union All
        Select '12' From Dual
      ) m
        Left Outer Join
      mydatatable t
        On
          m.Mo = to_char(t.dateentered, 'MM') And 
          t.dateentered >= DATE'2011-01-01' And
          t.dateentered < DATE'2012-01-01'
    Group By
      m.Mo
    Order By
      m.Mo
    

    Update used a more index friendly way of restricting the year.

    http://sqlfiddle.com/#!4/68085/10

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

Sidebar

Related Questions

I am looking to get a better understanding of Active Model/Record relationships and how
I got 2 pages ASP.NET (PageA.aspx and PageB.aspx). Each Page can display muliple records
When looking to get data from a web page whats the recommended method if
I'm looking to get a Regex for the following password strength requirements: Minimum 8
I'm looking to get an instance of Solr search running on my localhost. The
I'm looking to get up to speed on Python : Is it worth working
I am looking to get into operating system kernel development and figured my contribution
I am looking to get into operating system kernel development and figured and have
I am looking to get access to all HTTP traffic on my machine (my
We am looking to get a list of bugs per user story in TFS

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.