<?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/"
		>
<channel>
	<title>Comments on: SELECT TOP 1</title>
	<atom:link href="http://sqlserverplanet.com/tsql/select-top-1/feed" rel="self" type="application/rss+xml" />
	<link>http://sqlserverplanet.com/tsql/select-top-1</link>
	<description>Tips and Articles on SQL Server</description>
	<lastBuildDate>Wed, 16 May 2012 18:08:18 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: TradeItEasy</title>
		<link>http://sqlserverplanet.com/tsql/select-top-1/comment-page-1#comment-1178</link>
		<dc:creator>TradeItEasy</dc:creator>
		<pubDate>Tue, 24 Apr 2012 12:30:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlserverplanet.com/?p=1364#comment-1178</guid>
		<description>Just to add a Stat here:

On my Computer the 
    Nested Select has a Cost of 0.00677
whereas the
    Top 1 Select has a cost of 0.01485
because sorting the table alone costs you 0.01154. Sorting is very Time and Processor Intensive as you need to compare two values over and over again which means you go through your result set several times. So be aware of what you sort!

A tip for those who would like to compare two methods of Querying: Type your two Statements in the Query and look at the execution plan. It will tell you which query took how much of the whole Batch. In my example the Nested Select took 31% of the Batch and the Top 1 took 69%...</description>
		<content:encoded><![CDATA[<p>Just to add a Stat here:</p>
<p>On my Computer the<br />
    Nested Select has a Cost of 0.00677<br />
whereas the<br />
    Top 1 Select has a cost of 0.01485<br />
because sorting the table alone costs you 0.01154. Sorting is very Time and Processor Intensive as you need to compare two values over and over again which means you go through your result set several times. So be aware of what you sort!</p>
<p>A tip for those who would like to compare two methods of Querying: Type your two Statements in the Query and look at the execution plan. It will tell you which query took how much of the whole Batch. In my example the Nested Select took 31% of the Batch and the Top 1 took 69%&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: TradeItEasy</title>
		<link>http://sqlserverplanet.com/tsql/select-top-1/comment-page-1#comment-1177</link>
		<dc:creator>TradeItEasy</dc:creator>
		<pubDate>Tue, 24 Apr 2012 12:17:34 +0000</pubDate>
		<guid isPermaLink="false">http://sqlserverplanet.com/?p=1364#comment-1177</guid>
		<description>I would generally prefer to do the nested Select option as it takes only half the time.

Using the Top 1 Method may be convenient for Coding but does not pay off when it comes to runtime efficiency...

Always ask the query analyzer first ;-)</description>
		<content:encoded><![CDATA[<p>I would generally prefer to do the nested Select option as it takes only half the time.</p>
<p>Using the Top 1 Method may be convenient for Coding but does not pay off when it comes to runtime efficiency&#8230;</p>
<p>Always ask the query analyzer first <img src='http://sqlserverplanet.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Max</title>
		<link>http://sqlserverplanet.com/tsql/select-top-1/comment-page-1#comment-1173</link>
		<dc:creator>Max</dc:creator>
		<pubDate>Thu, 19 Apr 2012 18:37:50 +0000</pubDate>
		<guid isPermaLink="false">http://sqlserverplanet.com/?p=1364#comment-1173</guid>
		<description>Brenda, 
select max(date),event 
from eventTable 
group by event

or 

select top 1 date, event
from eventTable
group by event
order by date desc</description>
		<content:encoded><![CDATA[<p>Brenda,<br />
select max(date),event<br />
from eventTable<br />
group by event</p>
<p>or </p>
<p>select top 1 date, event<br />
from eventTable<br />
group by event<br />
order by date desc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brenda</title>
		<link>http://sqlserverplanet.com/tsql/select-top-1/comment-page-1#comment-868</link>
		<dc:creator>Brenda</dc:creator>
		<pubDate>Tue, 20 Sep 2011 11:53:54 +0000</pubDate>
		<guid isPermaLink="false">http://sqlserverplanet.com/?p=1364#comment-868</guid>
		<description>How can I find the most recent date of a repeating event?</description>
		<content:encoded><![CDATA[<p>How can I find the most recent date of a repeating event?</p>
]]></content:encoded>
	</item>
</channel>
</rss>

