<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: Basket Case – CASE statement in SQL</title>
	<atom:link href="http://mikesmithers.wordpress.com/2010/07/12/basket-case-%E2%80%93-case-statement-in-sql/feed/" rel="self" type="application/rss+xml" />
	<link>http://mikesmithers.wordpress.com/2010/07/12/basket-case-%e2%80%93-case-statement-in-sql/</link>
	<description>Oracle - for when it was like that when you got there</description>
	<lastBuildDate>Sat, 18 May 2013 06:13:06 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: glenm</title>
		<link>http://mikesmithers.wordpress.com/2010/07/12/basket-case-%e2%80%93-case-statement-in-sql/#comment-592</link>
		<dc:creator><![CDATA[glenm]]></dc:creator>
		<pubDate>Wed, 21 Jul 2010 04:00:27 +0000</pubDate>
		<guid isPermaLink="false">http://mikesmithers.wordpress.com/?p=519#comment-592</guid>
		<description><![CDATA[Sorry, I should have included an example :

select case when dummy is null then &#039;*null*&#039; else &#039;in else&#039; end 
from dual;

For completeness :

case var when val_1 then &#039;x&#039; else &#039;y&#039; end

is the same as

case when var = val_1 then &#039;x&#039; else &#039;y&#039; end

whereas

case var when null then &#039;x&#039; else &#039;y&#039; end

is the same as

case when var = null then &#039;x&#039; else &#039;y&#039; end

which is different to what you want 

case when var is null then &#039;x&#039; else &#039;y&#039; end]]></description>
		<content:encoded><![CDATA[<p>Sorry, I should have included an example :</p>
<p>select case when dummy is null then &#8216;*null*&#8217; else &#8216;in else&#8217; end<br />
from dual;</p>
<p>For completeness :</p>
<p>case var when val_1 then &#8216;x&#8217; else &#8216;y&#8217; end</p>
<p>is the same as</p>
<p>case when var = val_1 then &#8216;x&#8217; else &#8216;y&#8217; end</p>
<p>whereas</p>
<p>case var when null then &#8216;x&#8217; else &#8216;y&#8217; end</p>
<p>is the same as</p>
<p>case when var = null then &#8216;x&#8217; else &#8216;y&#8217; end</p>
<p>which is different to what you want </p>
<p>case when var is null then &#8216;x&#8217; else &#8216;y&#8217; end</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mikesmithers</title>
		<link>http://mikesmithers.wordpress.com/2010/07/12/basket-case-%e2%80%93-case-statement-in-sql/#comment-571</link>
		<dc:creator><![CDATA[mikesmithers]]></dc:creator>
		<pubDate>Wed, 14 Jul 2010 19:50:36 +0000</pubDate>
		<guid isPermaLink="false">http://mikesmithers.wordpress.com/?p=519#comment-571</guid>
		<description><![CDATA[Glenn,

I think you may have a point. However when you try the syntax you suggested :
SQL&gt; l
  1  SELECT team, best,
  2	 CASE winners WHEN winners IS NULL THEN
  3	     CASE runner_up WHEN runner_up IS NULL THEN
  4		 CASE third WHEN third IS NULL THEN fourth ELSE third END
  5	     ELSE runner_up END
  6	 ELSE winners END years
  7* FROM final_four
SQL&gt; /
    CASE winners WHEN winners IS NULL THEN
                              *
ERROR at line 2:
ORA-00905: missing keyword

This is the same when you reverse the logic ( i.e. WHEN winners IS NOT NULL).
This example is in SQL on Oracle 10g XE ( I also tried the stuff in the original post on 11gR2).

Not sure if you&#039;re example works on another RDBMS, but unfortunately, Oracle&#039;s having none of it.]]></description>
		<content:encoded><![CDATA[<p>Glenn,</p>
<p>I think you may have a point. However when you try the syntax you suggested :<br />
SQL&gt; l<br />
  1  SELECT team, best,<br />
  2	 CASE winners WHEN winners IS NULL THEN<br />
  3	     CASE runner_up WHEN runner_up IS NULL THEN<br />
  4		 CASE third WHEN third IS NULL THEN fourth ELSE third END<br />
  5	     ELSE runner_up END<br />
  6	 ELSE winners END years<br />
  7* FROM final_four<br />
SQL&gt; /<br />
    CASE winners WHEN winners IS NULL THEN<br />
                              *<br />
ERROR at line 2:<br />
ORA-00905: missing keyword</p>
<p>This is the same when you reverse the logic ( i.e. WHEN winners IS NOT NULL).<br />
This example is in SQL on Oracle 10g XE ( I also tried the stuff in the original post on 11gR2).</p>
<p>Not sure if you&#8217;re example works on another RDBMS, but unfortunately, Oracle&#8217;s having none of it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: glenm</title>
		<link>http://mikesmithers.wordpress.com/2010/07/12/basket-case-%e2%80%93-case-statement-in-sql/#comment-568</link>
		<dc:creator><![CDATA[glenm]]></dc:creator>
		<pubDate>Tue, 13 Jul 2010 22:28:21 +0000</pubDate>
		<guid isPermaLink="false">http://mikesmithers.wordpress.com/?p=519#comment-568</guid>
		<description><![CDATA[Your problem is related to the difference between &#039;if x = null&#039; and &#039;if x is null&#039;. When you say &#039;case x when null&#039; you doing an equality check which isn&#039;t giving you the result you want. Try &#039;case when x is null&#039; and you should get the desired result.

Glen]]></description>
		<content:encoded><![CDATA[<p>Your problem is related to the difference between &#8216;if x = null&#8217; and &#8216;if x is null&#8217;. When you say &#8216;case x when null&#8217; you doing an equality check which isn&#8217;t giving you the result you want. Try &#8216;case when x is null&#8217; and you should get the desired result.</p>
<p>Glen</p>
]]></content:encoded>
	</item>
</channel>
</rss>
