Excellent, thanks!

-----Original Message-----
From: Dean H. Saxe [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, September 27, 2001 12:39 PM
To: SQL
Subject: RE: Date Range Comparison


At 11:08 AM 9/27/01 -0400, you wrote:
>Wow, thanks...and I WILL pick up that book!
>
>What if v1.total_value somehow were zero? How does SQL handle these 
>types of errors? "Can not divide by zero" would be a typical error code 
>from my app server...

I didn't consider that.  First, you could specify that the first date must 
have a value other than 0, though I don't see why you would necessarily 
have 0 based values.  In Oracle you could use the decode() function as an 
"if..then.." block to return 100% increase year-over-year if the first year 
has a zero value, SQL server should have a similar function.  You could 
also do it as an outer join, since the method which I have chosen to do 
this will only return value for which there are the same month across 2 
different years, in which case you would have to look for 0 or NULL values 
and use decode() to handle them properly.

-dhs

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get the mailserver that powers this list at http://www.coolfusion.com
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to