Solved

Count for Day of Current Month Show Zero Values

Posted on 2010-09-15
3
230 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
3 Comments
 
LVL 76

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
From implementing a password expiration date, to datatype conversions and file export options, these are some useful settings I've found in Jasper Server.
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

910 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now