<?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: SQL SERVER &#8211; Fix: Error: 147 An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference</title>
	<atom:link href="http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Thu, 23 May 2013 14:22:59 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Raul</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-374208</link>
		<dc:creator><![CDATA[Raul]]></dc:creator>
		<pubDate>Wed, 14 Nov 2012 21:40:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-374208</guid>
		<description><![CDATA[Amazin!!!, i was stcke for the same mistake, so helpful!!!!]]></description>
		<content:encoded><![CDATA[<p>Amazin!!!, i was stcke for the same mistake, so helpful!!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Riandi</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-368744</link>
		<dc:creator><![CDATA[Riandi]]></dc:creator>
		<pubDate>Sat, 03 Nov 2012 17:57:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-368744</guid>
		<description><![CDATA[thanks boss it work from me in this my case]]></description>
		<content:encoded><![CDATA[<p>thanks boss it work from me in this my case</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Amit Srivastava</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-303123</link>
		<dc:creator><![CDATA[Amit Srivastava]]></dc:creator>
		<pubDate>Tue, 19 Jun 2012 09:47:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-303123</guid>
		<description><![CDATA[with cte as
(select row_number over(order by ShipDate DESC)ID,* from [Sales].[SalesOrderHeader])
Select * from cte where id=1]]></description>
		<content:encoded><![CDATA[<p>with cte as<br />
(select row_number over(order by ShipDate DESC)ID,* from [Sales].[SalesOrderHeader])<br />
Select * from cte where id=1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Venkat Kilari</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-301621</link>
		<dc:creator><![CDATA[Venkat Kilari]]></dc:creator>
		<pubDate>Fri, 15 Jun 2012 10:13:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-301621</guid>
		<description><![CDATA[Hi Sir,

SELECT TOP 1 * FROM [Sales].[SalesOrderHeader] ORDER BY ShipDate DESC

I Think this is the best way in performance wise..]]></description>
		<content:encoded><![CDATA[<p>Hi Sir,</p>
<p>SELECT TOP 1 * FROM [Sales].[SalesOrderHeader] ORDER BY ShipDate DESC</p>
<p>I Think this is the best way in performance wise..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Reggie</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-295495</link>
		<dc:creator><![CDATA[Reggie]]></dc:creator>
		<pubDate>Wed, 06 Jun 2012 19:57:46 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-295495</guid>
		<description><![CDATA[I would say this is the right way to do it. Not to forget that MAX function will have a significant impact on the overall performance (in the absence of a nolock it has the potential of locking the table as well - ofc this is only when the table contains large amount of data).]]></description>
		<content:encoded><![CDATA[<p>I would say this is the right way to do it. Not to forget that MAX function will have a significant impact on the overall performance (in the absence of a nolock it has the potential of locking the table as well &#8211; ofc this is only when the table contains large amount of data).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chirag Satasiya</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-295217</link>
		<dc:creator><![CDATA[Chirag Satasiya]]></dc:creator>
		<pubDate>Wed, 06 Jun 2012 12:01:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-295217</guid>
		<description><![CDATA[Hi pinal sir,

Alternative to above solution :

SELECT TOP 1 * FROM [Sales].[SalesOrderHeader] ORDER BY ShipDate DESC]]></description>
		<content:encoded><![CDATA[<p>Hi pinal sir,</p>
<p>Alternative to above solution :</p>
<p>SELECT TOP 1 * FROM [Sales].[SalesOrderHeader] ORDER BY ShipDate DESC</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ramdas</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-293962</link>
		<dc:creator><![CDATA[Ramdas]]></dc:creator>
		<pubDate>Mon, 04 Jun 2012 18:51:37 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-293962</guid>
		<description><![CDATA[There are multiple ways to do the same thing in SQL. One of the things one could do is instead of thinking in syntactical fashion is to start with the data and see where one needs to get to that could help one to get different solutions.]]></description>
		<content:encoded><![CDATA[<p>There are multiple ways to do the same thing in SQL. One of the things one could do is instead of thinking in syntactical fashion is to start with the data and see where one needs to get to that could help one to get different solutions.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jorge</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-293868</link>
		<dc:creator><![CDATA[Jorge]]></dc:creator>
		<pubDate>Mon, 04 Jun 2012 16:42:22 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-293868</guid>
		<description><![CDATA[Nice alternative, especially if I have to sort by &quot;Ship Date&quot; once]]></description>
		<content:encoded><![CDATA[<p>Nice alternative, especially if I have to sort by &#8220;Ship Date&#8221; once</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aas4mis</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-293783</link>
		<dc:creator><![CDATA[aas4mis]]></dc:creator>
		<pubDate>Mon, 04 Jun 2012 13:54:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-293783</guid>
		<description><![CDATA[WITH Max_Ship_Date AS (
SELECT Date_Shipped = MAX(ShipDate)
FROM SalesOrderHeader
)
SELECT *
FROM SalesOrderHeader
INNER JOIN Max_Ship_Date ON
SalesOrderHeader.ShipDate = Max_Ship_Date.Date_Shipped]]></description>
		<content:encoded><![CDATA[<p>WITH Max_Ship_Date AS (<br />
SELECT Date_Shipped = MAX(ShipDate)<br />
FROM SalesOrderHeader<br />
)<br />
SELECT *<br />
FROM SalesOrderHeader<br />
INNER JOIN Max_Ship_Date ON<br />
SalesOrderHeader.ShipDate = Max_Ship_Date.Date_Shipped</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Hemal Shah</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-293627</link>
		<dc:creator><![CDATA[Hemal Shah]]></dc:creator>
		<pubDate>Mon, 04 Jun 2012 07:10:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-293627</guid>
		<description><![CDATA[Hello pinal,

its very nice post.

There is one another way to do this.

http://techtreasure.in/2012/05/28/alternate-way-to-find-minmax-using-row_number/]]></description>
		<content:encoded><![CDATA[<p>Hello pinal,</p>
<p>its very nice post.</p>
<p>There is one another way to do this.</p>
<p><a href="http://techtreasure.in/2012/05/28/alternate-way-to-find-minmax-using-row_number/" rel="nofollow">http://techtreasure.in/2012/05/28/alternate-way-to-find-minmax-using-row_number/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Prakash</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-293579</link>
		<dc:creator><![CDATA[Prakash]]></dc:creator>
		<pubDate>Mon, 04 Jun 2012 05:11:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-293579</guid>
		<description><![CDATA[Is there any performance issue if the data is growth in SalesOrderHeader, because we are using same table reference (SalesOrderHeader)]]></description>
		<content:encoded><![CDATA[<p>Is there any performance issue if the data is growth in SalesOrderHeader, because we are using same table reference (SalesOrderHeader)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alexey Rokhin</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-293557</link>
		<dc:creator><![CDATA[Alexey Rokhin]]></dc:creator>
		<pubDate>Mon, 04 Jun 2012 04:29:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-293557</guid>
		<description><![CDATA[select top (1) with ties * from [Sales].[SalesOrderHeader] order by ShipDate desc]]></description>
		<content:encoded><![CDATA[<p>select top (1) with ties * from [Sales].[SalesOrderHeader] order by ShipDate desc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manjuke Fernando</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-293337</link>
		<dc:creator><![CDATA[Manjuke Fernando]]></dc:creator>
		<pubDate>Sun, 03 Jun 2012 14:58:59 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-293337</guid>
		<description><![CDATA[** Common Table Expression. Sorry for the spelling mistake..]]></description>
		<content:encoded><![CDATA[<p>** Common Table Expression. Sorry for the spelling mistake..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manjuke Fernando</title>
		<link>http://blog.sqlauthority.com/2012/06/03/sql-server-fix-error-147-an-aggregate-may-not-appear-in-the-where-clause-unless-it-is-in-a-subquery-contained-in-a-having-clause-or-a-select-list-and-the-column-being-aggregated-is-an-outer-refer/#comment-293336</link>
		<dc:creator><![CDATA[Manjuke Fernando]]></dc:creator>
		<pubDate>Sun, 03 Jun 2012 14:56:39 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19091#comment-293336</guid>
		<description><![CDATA[How about using a Common TablenExpression, instead of having the inline sub query?]]></description>
		<content:encoded><![CDATA[<p>How about using a Common TablenExpression, instead of having the inline sub query?</p>
]]></content:encoded>
	</item>
</channel>
</rss>
