Solved

Count for Day of Current Month Show Zero Values

Posted on 2010-09-15
3
238 Views
Last Modified: 2012-05-10
Please refer to a previous question I posted about counts per month.
http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/Cold_Fusion_Markup_Language/Q_26459915.html

I would like to do the same thing but count for each day of current month, and if there is a zero count, i would like that to show as well.

Here was the query the was worked out for count of month.

SELECT TO_CHAR(m, 'mm yyyy') AS themonth, COUNT(q.quote_id) AS numoflosses
    FROM     q_quotes q
         RIGHT JOIN
             (    SELECT TO_DATE('2009' || TO_CHAR(LEVEL, 'fm09'), 'yyyymm') m
                    FROM DUAL
              CONNECT BY LEVEL <= 12)
         ON q.quote_status_id IN (8, 10, 13)
        AND q.quote_dt >= m
        AND q.quote_dt < ADD_MONTHS(m, 1)
        AND q.quote_id NOT IN (  SELECT linked_quote_id FROM q_quote_links)
GROUP BY m
ORDER BY m ASC;
0
Comment
Question by:theideabulb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 500 total points
ID: 33683029
Off the top of my head change the connect by to something like:

SELECT TO_DATE('2009' || to_char(sysdate,'mm') || TO_CHAR(LEVEL, 'fm09'), 'yyyymmdd') m
FROM DUAL
CONNECT BY LEVEL <= to_number(to_char(last_day(sysdate),'dd'))
0
 
LVL 6

Expert Comment

by:reiters
ID: 33692140
I've always resorted to getting the recordset and then looping over it and putting the results into a new handmade recordset and adding the missing ones myself.  I could never find a way to make a DB return a result where no results exist.
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
This video shows information on the Oracle Data Dictionary, starting with the Oracle documentation, explaining the different types of Data Dictionary views available by group and permissions as well as giving examples on how to retrieve data from th…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question