jexley
14-05-2009, 09:19 AM
Hello my fellow geeklings,
I've got an app that needs to chart a bit of data for every day of a selected month. If I had date, text and number, May would be like:
01-05-2009-"Anthony"-4 | 01-05-2009-"Joe"-3 | 01-05-2009-"Mark"-5
02-05-2009-"Anthony"-5 | 02-05-2009-"Joe"-6 | 02-05-2009-"Mark"-8
03-05-2009-"Anthony"-2 | 03-05-2009-"Joe"-4 | 03-05-2009-"Mark"-6
Now, what I've got is easy enough to do that, but I run into problems when I graph it and there's days missing. Like so:
01-05-2009-"Anthony"-4 | 01-05-2009-"Joe"-3 | 01-05-2009-"Mark"-5
03-05-2009-"Anthony"-2 | 03-05-2009-"Joe"-4 | 03-05-2009-"Mark"-6
The graph that I've got isn't smart enough to see that there's a gap, it just displays the value in the graph for "Anthony" as "2" right after the "4" with no "0" in between.
Any ideas on a SQL statement that can pull back a date range, like data for all 30+ days in a month, but plug in 0 where there actually is no data?
Oh, ftr my SQL is:
select b.Date, a.Name, b.Hits from Contacts a, Occurences b
where a.CompanyID = 61
and a.ContactID = b.ContactID
and b.Date BETWEEN '2009-05-01' AND '2009-05-31'
order by a.ContactID, b.DateCheers for the help kids, much appreciated.
I've got an app that needs to chart a bit of data for every day of a selected month. If I had date, text and number, May would be like:
01-05-2009-"Anthony"-4 | 01-05-2009-"Joe"-3 | 01-05-2009-"Mark"-5
02-05-2009-"Anthony"-5 | 02-05-2009-"Joe"-6 | 02-05-2009-"Mark"-8
03-05-2009-"Anthony"-2 | 03-05-2009-"Joe"-4 | 03-05-2009-"Mark"-6
Now, what I've got is easy enough to do that, but I run into problems when I graph it and there's days missing. Like so:
01-05-2009-"Anthony"-4 | 01-05-2009-"Joe"-3 | 01-05-2009-"Mark"-5
03-05-2009-"Anthony"-2 | 03-05-2009-"Joe"-4 | 03-05-2009-"Mark"-6
The graph that I've got isn't smart enough to see that there's a gap, it just displays the value in the graph for "Anthony" as "2" right after the "4" with no "0" in between.
Any ideas on a SQL statement that can pull back a date range, like data for all 30+ days in a month, but plug in 0 where there actually is no data?
Oh, ftr my SQL is:
select b.Date, a.Name, b.Hits from Contacts a, Occurences b
where a.CompanyID = 61
and a.ContactID = b.ContactID
and b.Date BETWEEN '2009-05-01' AND '2009-05-31'
order by a.ContactID, b.DateCheers for the help kids, much appreciated.