Create a very simple table called "Hours" with an integer column named
"HourOfDay".

Then, insert 24 records such as:

HourOfDay
---------
1
2
3
4
5
6
7
....
23
24

(You may need to use 0-23 instead of 1-24.)

Then, OUTER JOIN the tables such as:

SELECT
  Hours.HourOfDay, Articles.ArticleText
FROM
  Hours
LEFT OUTER JOIN
  Articles ON Hours.HourOfDay = HOUR(Articles.ArticleDate)
WHERE
  Articles.ArticleDate = #cf_date_goes_here#
ORDER BY
  Hours.HourOfDay

You will always get all 24 records from the Hours table and any matching
records from the article table, as long as you ONLY have one article per
hour.

The Hours table will "fill up" any gaps, however, it won't prevent any
extra records.  For example, if there were two articles posted between
9-10, then you would get 25 records.

M!ke

-----Original Message-----
From: Robert Rawlins - Think Blue
[mailto:[EMAIL PROTECTED] 
Sent: Friday, May 04, 2007 9:28 AM
To: CF-Talk
Subject: RE: Table Data

Thanks Michael,

That first solution sounds like a nice idea, would you be able to
elaborate a little more? I'd much rather have my SQLServer do the work
for me.

Thanks,

Rob

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
ColdFusion MX7 and Flex 2 
Build sales & marketing dashboard RIA’s for your business. Upgrade now
http://www.adobe.com/products/coldfusion/flex2?sdid=RVJT

Archive: 
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:277040
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to