<?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>TiagoFigueira.com &#187; NULL</title>
	<atom:link href="http://tiagofigueira.com/tag/null/feed/" rel="self" type="application/rss+xml" />
	<link>http://tiagofigueira.com</link>
	<description>Web Developer &#38; SysAdmin</description>
	<lastBuildDate>Thu, 24 Jun 2010 01:36:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>SQL Server &#8211; Order by com valores NULL</title>
		<link>http://tiagofigueira.com/sql-server-order-by-com-valores-null/14/</link>
		<comments>http://tiagofigueira.com/sql-server-order-by-com-valores-null/14/#comments</comments>
		<pubDate>Sun, 19 Jul 2009 23:59:29 +0000</pubDate>
		<dc:creator>tiago</dc:creator>
				<category><![CDATA[base de dados]]></category>
		<category><![CDATA[NULL]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://tiagofigueira.com/?p=14</guid>
		<description><![CDATA[Imaginem uma tabela (alunos) com dois campos: Nome e Numero. Ao executar o seguinte código, SELEC T * FROM ALUNOS ORDER BY numero; obtemos como resultado: Para obtermos dos alunos ordenados por número sem ter em conta os NULL temos de alterar o código sql para: SELEC T * FROM ALUNOS ORDER BY (CASE WHEN [...]]]></description>
			<content:encoded><![CDATA[<p>Imaginem uma tabela (alunos) com dois campos: Nome e Numero.</p>
<p><img class="alignnone size-full wp-image-64" title="table-alunos" src="http://tiagofigueira.com/wp-content/uploads/2009/07/table-alunos.png" alt="table-alunos" width="262" height="91" /></p>
<p>Ao executar o seguinte código,</p>
<pre class="brush: sql;">SELEC T * FROM ALUNOS ORDER BY numero;</pre>
<p>obtemos como resultado:</p>
<p><img class="alignnone size-full wp-image-65" title="table-alunos-order-by" src="http://tiagofigueira.com/wp-content/uploads/2009/07/table-alunos-order-by.png" alt="table-alunos-order-by" width="181" height="164" /></p>
<p>Para obtermos dos alunos ordenados por número sem ter em conta os NULL temos de alterar o código sql para:</p>
<pre class="brush: sql;">SELEC T * FROM ALUNOS ORDER BY (CASE WHEN numero IS NULL THEN 1 ELSE 0 END), numero;</pre>
<p>Assim obtemos como resultado:</p>
<p><img class="alignnone size-full wp-image-66" title="table-alunos-order-by-null" src="http://tiagofigueira.com/wp-content/uploads/2009/07/table-alunos-order-by-null.png" alt="table-alunos-order-by-null" width="146" height="141" /></p>
<p> <img src='http://tiagofigueira.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://tiagofigueira.com/sql-server-order-by-com-valores-null/14/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
