<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Homespun &#187; databases</title>
	<atom:link href="http://www.janinedalton.com/blog/archives/category/web-dev/databases/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.janinedalton.com/blog</link>
	<description>Random ramblings from a freelance web developer in Dublin, Ireland</description>
	<lastBuildDate>Tue, 31 May 2011 09:23:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>calculated columns in sql server</title>
		<link>http://www.janinedalton.com/blog/archives/2005/calculated-columns-in-sql-server/</link>
		<comments>http://www.janinedalton.com/blog/archives/2005/calculated-columns-in-sql-server/#comments</comments>
		<pubDate>Tue, 18 Jan 2005 08:00:05 +0000</pubDate>
		<dc:creator>janine</dc:creator>
				<category><![CDATA[databases]]></category>

		<guid isPermaLink="false">http://janinedalton.com/wp/?p=42</guid>
		<description><![CDATA[I frequently suffer from Mondayitis but it can strike on Tuesdays too! I was creating a stored procedure in SQL Server this morning involving GROUP BY, CASE statements, aggregate functions, ISNULL and COALESCE for good measure. Everything was working fine, except that one of the calculated columns was zero all the way down, even though [...]]]></description>
			<content:encoded><![CDATA[<p>I frequently suffer from <a href="http://www.e-paranoids.com/m/mo/mondayitis.html" title="i want to be under my duvet">Mondayitis</a> but it can strike on Tuesdays too!</p>
<p>I was creating a stored procedure in SQL Server this morning involving GROUP BY, CASE statements, aggregate functions, ISNULL and COALESCE for good measure. Everything was working fine, except that one of the calculated columns was zero all the way down, even though none of the data was. The same data was used in calculations for other columns and was giving the correct answer so it seemed bizarre to me. I tried removing a function here and a function there to figure out what the hell was going on&#8230;</p>
<p>And then *finally* it hit me&#8230; I was dividing 2 integer columns! Yes, that rudimentary programming lesson about rounding precision when working with numeric data types was lost on me <img src='http://www.janinedalton.com/blog/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  So, once I changed SUM(a)/SUM(b) to CAST(SUM(a) AS FLOAT)/SUM(b) everything was OK. Phew! </p>
<p>I document this nonsense here because I just *know* I&#8217;ll do it again someday and maybe I&#8217;m not the only silly billy??? What a muppet I am <img src='http://www.janinedalton.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.janinedalton.com/blog/archives/2005/calculated-columns-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

