<?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; Query to Get Unique Distinct Data Based on Condition &#8211; Eliminate Duplicate Data from Resultset</title>
	<atom:link href="http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: srbhogayta</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-465992</link>
		<dc:creator><![CDATA[srbhogayta]]></dc:creator>
		<pubDate>Mon, 29 Apr 2013 07:31:12 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-465992</guid>
		<description><![CDATA[hello, sir
I am using row_number 2 times in my sp so, it is right or not ? I want to display records as per distinct url and i have already used row_number for paging in my stored procedure. so, how can i display the records with unique url. please help asap....
thanks]]></description>
		<content:encoded><![CDATA[<p>hello, sir<br />
I am using row_number 2 times in my sp so, it is right or not ? I want to display records as per distinct url and i have already used row_number for paging in my stored procedure. so, how can i display the records with unique url. please help asap&#8230;.<br />
thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jagadeesh Bollabathini</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-427181</link>
		<dc:creator><![CDATA[Jagadeesh Bollabathini]]></dc:creator>
		<pubDate>Mon, 25 Feb 2013 05:23:03 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-427181</guid>
		<description><![CDATA[It helped me.

Thank u so much......
you reduced my R &amp; D work.]]></description>
		<content:encoded><![CDATA[<p>It helped me.</p>
<p>Thank u so much&#8230;&#8230;<br />
you reduced my R &amp; D work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tim</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-330361</link>
		<dc:creator><![CDATA[tim]]></dc:creator>
		<pubDate>Tue, 14 Aug 2012 13:40:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-330361</guid>
		<description><![CDATA[coolpal9 :

Again, being a MySQL guy, my first response was group_concat. So, I took that and searched for group_concat equivalent in MS SQL, and found this:

http://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-ms-sql-server-2005

Hope that link helps you do what you want to do. Looks to be what you are asking for.

(also, my post above is incorrect - it should be just SELECT * FROM ( ... - without the &#039;t&#039; after the from )]]></description>
		<content:encoded><![CDATA[<p>coolpal9 :</p>
<p>Again, being a MySQL guy, my first response was group_concat. So, I took that and searched for group_concat equivalent in MS SQL, and found this:</p>
<p><a href="http://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-ms-sql-server-2005" rel="nofollow">http://stackoverflow.com/questions/451415/simulating-group-concat-mysql-function-in-ms-sql-server-2005</a></p>
<p>Hope that link helps you do what you want to do. Looks to be what you are asking for.</p>
<p>(also, my post above is incorrect &#8211; it should be just SELECT * FROM ( &#8230; &#8211; without the &#8216;t&#8217; after the from )</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: joshp84</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-330039</link>
		<dc:creator><![CDATA[joshp84]]></dc:creator>
		<pubDate>Tue, 14 Aug 2012 00:00:18 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-330039</guid>
		<description><![CDATA[...and so the question remains - which is fastest / best? :)]]></description>
		<content:encoded><![CDATA[<p>&#8230;and so the question remains &#8211; which is fastest / best? :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: coolpal9</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-329697</link>
		<dc:creator><![CDATA[coolpal9]]></dc:creator>
		<pubDate>Mon, 13 Aug 2012 07:42:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-329697</guid>
		<description><![CDATA[thanks for updating me with this. Now suppose if I want to display the Product and Color, where all colors corresponding to the Product are dispalyed together separated with comma.

I am attempting to do something like this and I am not finding the prper solution. Pl help me with it…]]></description>
		<content:encoded><![CDATA[<p>thanks for updating me with this. Now suppose if I want to display the Product and Color, where all colors corresponding to the Product are dispalyed together separated with comma.</p>
<p>I am attempting to do something like this and I am not finding the prper solution. Pl help me with it…</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tim</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-322569</link>
		<dc:creator><![CDATA[tim]]></dc:creator>
		<pubDate>Tue, 31 Jul 2012 19:12:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-322569</guid>
		<description><![CDATA[In MySQL, this is very strait-forward:

select * from t
(select * from Table1 order by product, price DESC) as t
group by product

it will preserve the order of the sub-query, and take the first record when grouping. Seems like MSSQL is aways more complicated than necessary.]]></description>
		<content:encoded><![CDATA[<p>In MySQL, this is very strait-forward:</p>
<p>select * from t<br />
(select * from Table1 order by product, price DESC) as t<br />
group by product</p>
<p>it will preserve the order of the sub-query, and take the first record when grouping. Seems like MSSQL is aways more complicated than necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chris Ross</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-322428</link>
		<dc:creator><![CDATA[Chris Ross]]></dc:creator>
		<pubDate>Tue, 31 Jul 2012 13:20:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-322428</guid>
		<description><![CDATA[To return a de-duped value to an outer table

Select outer.column, inner.column
From dbo.outer
 cross apply (
    Select top 1 column
     From table
     Where outer.id = table.id
    Order by sortcolumn
) inner]]></description>
		<content:encoded><![CDATA[<p>To return a de-duped value to an outer table</p>
<p>Select outer.column, inner.column<br />
From dbo.outer<br />
 cross apply (<br />
    Select top 1 column<br />
     From table<br />
     Where outer.id = table.id<br />
    Order by sortcolumn<br />
) inner</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nagendra Srinivas Gubbal</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-322248</link>
		<dc:creator><![CDATA[nagendra Srinivas Gubbal]]></dc:creator>
		<pubDate>Tue, 31 Jul 2012 07:14:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-322248</guid>
		<description><![CDATA[with NQ as 
(SELECT Product,Price,Color ,ROW_NUMBER() Over(Partition by Product Order by Price desc ) as RowNum 
FROM [TempProduct])
 
SELECT Product,Price,Color from NQ 
where RowNum = 1]]></description>
		<content:encoded><![CDATA[<p>with NQ as<br />
(SELECT Product,Price,Color ,ROW_NUMBER() Over(Partition by Product Order by Price desc ) as RowNum<br />
FROM [TempProduct])</p>
<p>SELECT Product,Price,Color from NQ<br />
where RowNum = 1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michal Kaczmarski</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-322240</link>
		<dc:creator><![CDATA[Michal Kaczmarski]]></dc:creator>
		<pubDate>Tue, 31 Jul 2012 07:06:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-322240</guid>
		<description><![CDATA[-- Query Cost: 36%
;WITH CTE AS (
SELECT Product, MAX(Price) Price
FROM TABLE1
GROUP BY Product
)

SELECT CTE.Product, CTE.Price, Table1.Color
FROM CTE
JOIN Table1 ON CTE.Product = Table1.Product AND CTE.Price = Table1.Price

GO

-- Query Cost: 64%
SELECT Product, Price, Color
FROM
(SELECT Table1.*,
ROW_NUMBER() OVER (PARTITION BY Product ORDER BY Price DESC) AS RN
FROM Table1) AS t
WHERE RN = 1
ORDER BY ID]]></description>
		<content:encoded><![CDATA[<p>&#8211; Query Cost: 36%<br />
;WITH CTE AS (<br />
SELECT Product, MAX(Price) Price<br />
FROM TABLE1<br />
GROUP BY Product<br />
)</p>
<p>SELECT CTE.Product, CTE.Price, Table1.Color<br />
FROM CTE<br />
JOIN Table1 ON CTE.Product = Table1.Product AND CTE.Price = Table1.Price</p>
<p>GO</p>
<p>&#8211; Query Cost: 64%<br />
SELECT Product, Price, Color<br />
FROM<br />
(SELECT Table1.*,<br />
ROW_NUMBER() OVER (PARTITION BY Product ORDER BY Price DESC) AS RN<br />
FROM Table1) AS t<br />
WHERE RN = 1<br />
ORDER BY ID</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Selva</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-321873</link>
		<dc:creator><![CDATA[Selva]]></dc:creator>
		<pubDate>Mon, 30 Jul 2012 14:23:43 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-321873</guid>
		<description><![CDATA[Dear  Venkatesh,

           We need color also... If our requirement is to  fetch The Product and Maximum Price only mean Your Query is Enough . But our requirement is to fetch the color also, So only we need such type of Different Query .

According to the requirement the query may vary  .]]></description>
		<content:encoded><![CDATA[<p>Dear  Venkatesh,</p>
<p>           We need color also&#8230; If our requirement is to  fetch The Product and Maximum Price only mean Your Query is Enough . But our requirement is to fetch the color also, So only we need such type of Different Query .</p>
<p>According to the requirement the query may vary  .</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dselvag</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-321798</link>
		<dc:creator><![CDATA[dselvag]]></dc:creator>
		<pubDate>Mon, 30 Jul 2012 11:42:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-321798</guid>
		<description><![CDATA[Other Solution .. 

Select Distinct Product, Price , Color
From Table1
Where price in (Select Max(z.Price)From Table1 z Where z.Product=Table1.product Group by Product)
Order By Price Desc]]></description>
		<content:encoded><![CDATA[<p>Other Solution .. </p>
<p>Select Distinct Product, Price , Color<br />
From Table1<br />
Where price in (Select Max(z.Price)From Table1 z Where z.Product=Table1.product Group by Product)<br />
Order By Price Desc</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dselvag</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-321794</link>
		<dc:creator><![CDATA[dselvag]]></dc:creator>
		<pubDate>Mon, 30 Jul 2012 11:28:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-321794</guid>
		<description><![CDATA[Nice]]></description>
		<content:encoded><![CDATA[<p>Nice</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: JO</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-320214</link>
		<dc:creator><![CDATA[JO]]></dc:creator>
		<pubDate>Sat, 28 Jul 2012 08:20:27 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-320214</guid>
		<description><![CDATA[SELECT Product, Price, Color
FROM Table_test b
where exists(Select 1 from 
(
Select product, MAX(price)price
from  Table_test
group by product)a where a.Product = b.Product and a.price = b.Price)]]></description>
		<content:encoded><![CDATA[<p>SELECT Product, Price, Color<br />
FROM Table_test b<br />
where exists(Select 1 from<br />
(<br />
Select product, MAX(price)price<br />
from  Table_test<br />
group by product)a where a.Product = b.Product and a.price = b.Price)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Venkatesh(fresher )</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-320076</link>
		<dc:creator><![CDATA[Venkatesh(fresher )]]></dc:creator>
		<pubDate>Sat, 28 Jul 2012 01:45:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-320076</guid>
		<description><![CDATA[select Product,max(Price) from table1 group by Product 

when i run this query it also returns the same result how can i know where to use and what the difference between  ur query and this query ......................]]></description>
		<content:encoded><![CDATA[<p>select Product,max(Price) from table1 group by Product </p>
<p>when i run this query it also returns the same result how can i know where to use and what the difference between  ur query and this query &#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rishab Arora</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-320002</link>
		<dc:creator><![CDATA[Rishab Arora]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 21:44:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-320002</guid>
		<description><![CDATA[Select distinct B.product , B.Price, B.Color
from table_1 B
join
(Select product, max(price) max_price from table_1 group by product) A
on A.product = B.product and A.max_price = B.Price]]></description>
		<content:encoded><![CDATA[<p>Select distinct B.product , B.Price, B.Color<br />
from table_1 B<br />
join<br />
(Select product, max(price) max_price from table_1 group by product) A<br />
on A.product = B.product and A.max_price = B.Price</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ed</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319866</link>
		<dc:creator><![CDATA[Ed]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 14:23:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319866</guid>
		<description><![CDATA[SELECT p.Product, p.Price, p.Color
FROM Table1 p
INNER JOIN (
SELECT product, MAX(price) as Price
FROM Table1
GROUP by Product ) q on p.product = q.Product and p.price = q.Price
ORDER BY ID

This is the same as other posts, but may not always yield the same results as the original solution.  If you add another row to the original table, you would up with duplicate products if the max price of a product is available in more than one color.

INSERT INTO Table1
SELECT 8, &#039;Pencil&#039;, 200, &#039;Brown&#039;

Results
Product	Price	Color
Toy	100	Black
Pen	100	Black
Pencil	200	Yellow
Cup	400	Brown
Pencil	200	Brown

The original solution returns the same 4 rows as it did before.]]></description>
		<content:encoded><![CDATA[<p>SELECT p.Product, p.Price, p.Color<br />
FROM Table1 p<br />
INNER JOIN (<br />
SELECT product, MAX(price) as Price<br />
FROM Table1<br />
GROUP by Product ) q on p.product = q.Product and p.price = q.Price<br />
ORDER BY ID</p>
<p>This is the same as other posts, but may not always yield the same results as the original solution.  If you add another row to the original table, you would up with duplicate products if the max price of a product is available in more than one color.</p>
<p>INSERT INTO Table1<br />
SELECT 8, &#8216;Pencil&#8217;, 200, &#8216;Brown&#8217;</p>
<p>Results<br />
Product	Price	Color<br />
Toy	100	Black<br />
Pen	100	Black<br />
Pencil	200	Yellow<br />
Cup	400	Brown<br />
Pencil	200	Brown</p>
<p>The original solution returns the same 4 rows as it did before.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nelson John</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319827</link>
		<dc:creator><![CDATA[Nelson John]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 12:40:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319827</guid>
		<description><![CDATA[For Better performance and readability 

with cte(RN,Product,Price,color)
as 
(
SELECT 
RN=row_number() over (PARTITION BY Product order by price desc )  ,
Product, Price, Color
FROM Table1 
)
select * from cte where RN=1


In case we are into older version of sql and to make compatible with other RDBMS sysstems 

select T.Product,T.Price,T.color
from
Table1 T inner join (select Product,max(Price) as Price from Table1 group by Product) VT
on t.Product=VT.Product and t.Price=VT.Price

Thanks
Nelson 
[Web Addressed moved to URL field]]]></description>
		<content:encoded><![CDATA[<p>For Better performance and readability </p>
<p>with cte(RN,Product,Price,color)<br />
as<br />
(<br />
SELECT<br />
RN=row_number() over (PARTITION BY Product order by price desc )  ,<br />
Product, Price, Color<br />
FROM Table1<br />
)<br />
select * from cte where RN=1</p>
<p>In case we are into older version of sql and to make compatible with other RDBMS sysstems </p>
<p>select T.Product,T.Price,T.color<br />
from<br />
Table1 T inner join (select Product,max(Price) as Price from Table1 group by Product) VT<br />
on t.Product=VT.Product and t.Price=VT.Price</p>
<p>Thanks<br />
Nelson<br />
[Web Addressed moved to URL field]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Purna Magum</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319725</link>
		<dc:creator><![CDATA[Purna Magum]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 07:21:33 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319725</guid>
		<description><![CDATA[Excellent]]></description>
		<content:encoded><![CDATA[<p>Excellent</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nash</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319696</link>
		<dc:creator><![CDATA[Nash]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 06:18:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319696</guid>
		<description><![CDATA[WITH Test(Product,Price) AS
( SELECT Product,MAX(Price)
  FROM Table1
  GROUP BY Product
)SELECT A.*,B.Color FROM Test A JOIN Table1 B ON A.Product =B.Product AND A.Price =B.Price]]></description>
		<content:encoded><![CDATA[<p>WITH Test(Product,Price) AS<br />
( SELECT Product,MAX(Price)<br />
  FROM Table1<br />
  GROUP BY Product<br />
)SELECT A.*,B.Color FROM Test A JOIN Table1 B ON A.Product =B.Product AND A.Price =B.Price</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319689</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 05:48:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319689</guid>
		<description><![CDATA[Thanks and fixed.]]></description>
		<content:encoded><![CDATA[<p>Thanks and fixed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Taher</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319687</link>
		<dc:creator><![CDATA[Taher]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 05:43:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319687</guid>
		<description><![CDATA[Just a observation: Spelling mistake in the post title
Eleminate -- It should be Eliminate :)]]></description>
		<content:encoded><![CDATA[<p>Just a observation: Spelling mistake in the post title<br />
Eleminate &#8212; It should be Eliminate :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harsh</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319683</link>
		<dc:creator><![CDATA[Harsh]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 05:37:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319683</guid>
		<description><![CDATA[Minor Changes to Original Solution:

This will bring highest priced latest record. 

SELECT Product, Price, Color
FROM
(SELECT Table1.*,
RANK() OVER (PARTITION BY Product ORDER BY Price DESC,ID DESC) AS RN
FROM Table1) AS t
WHERE RN = 1
ORDER BY ID]]></description>
		<content:encoded><![CDATA[<p>Minor Changes to Original Solution:</p>
<p>This will bring highest priced latest record. </p>
<p>SELECT Product, Price, Color<br />
FROM<br />
(SELECT Table1.*,<br />
RANK() OVER (PARTITION BY Product ORDER BY Price DESC,ID DESC) AS RN<br />
FROM Table1) AS t<br />
WHERE RN = 1<br />
ORDER BY ID</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harsh</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319672</link>
		<dc:creator><![CDATA[Harsh]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 04:56:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319672</guid>
		<description><![CDATA[SELECT table2.Product, table2.price, MAX(Table1.Color) AS Color
FROM         
	(SELECT     Product, MAX(Price) AS price
	FROM Table1 AS t
	GROUP BY Product) AS table2 
	INNER JOIN
	Table1 ON Table1.Product = table2.Product AND Table1.Price = table2.price
GROUP BY table2.Product, table2.price]]></description>
		<content:encoded><![CDATA[<p>SELECT table2.Product, table2.price, MAX(Table1.Color) AS Color<br />
FROM<br />
	(SELECT     Product, MAX(Price) AS price<br />
	FROM Table1 AS t<br />
	GROUP BY Product) AS table2<br />
	INNER JOIN<br />
	Table1 ON Table1.Product = table2.Product AND Table1.Price = table2.price<br />
GROUP BY table2.Product, table2.price</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harsh</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319670</link>
		<dc:creator><![CDATA[Harsh]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 04:54:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319670</guid>
		<description><![CDATA[SELECT DISTINCT Product,
	(SELECT TOP (1) Price FROM Table1
	WHERE (t1.Product = Product) ORDER BY Price DESC) AS Price,
	(SELECT TOP (1) Color FROM Table1
	WHERE (t1.Product = Product) ORDER BY Price DESC) AS Color
FROM Table1 AS t1]]></description>
		<content:encoded><![CDATA[<p>SELECT DISTINCT Product,<br />
	(SELECT TOP (1) Price FROM Table1<br />
	WHERE (t1.Product = Product) ORDER BY Price DESC) AS Price,<br />
	(SELECT TOP (1) Color FROM Table1<br />
	WHERE (t1.Product = Product) ORDER BY Price DESC) AS Color<br />
FROM Table1 AS t1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepa</title>
		<link>http://blog.sqlauthority.com/2012/07/27/sql-server-query-to-get-unique-distinct-data-based-on-condition-eleminate-duplicate-data-from-resultset/#comment-319662</link>
		<dc:creator><![CDATA[Deepa]]></dc:creator>
		<pubDate>Fri, 27 Jul 2012 04:31:07 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=19999#comment-319662</guid>
		<description><![CDATA[SELECT B.Product, A.Price, b.color
FROM (SELECT Product, MAX(Price) AS price
FRom table1
group by Product) A JOIN TABLE1 B
ON A.Price = B.Price AND A.Product = B.Product
order by 1]]></description>
		<content:encoded><![CDATA[<p>SELECT B.Product, A.Price, b.color<br />
FROM (SELECT Product, MAX(Price) AS price<br />
FRom table1<br />
group by Product) A JOIN TABLE1 B<br />
ON A.Price = B.Price AND A.Product = B.Product<br />
order by 1</p>
]]></content:encoded>
	</item>
</channel>
</rss>
