<?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; Difference between DISTINCT and GROUP BY &#8211; Distinct vs Group By</title>
	<atom:link href="http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Mon, 13 Feb 2012 15:11:24 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: Muhammad Umer</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-208739</link>
		<dc:creator><![CDATA[Muhammad Umer]]></dc:creator>
		<pubDate>Thu, 01 Dec 2011 16:51:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-208739</guid>
		<description><![CDATA[Dear all i need a help from you people. I am using vb6 &amp; ms sql server2000. I have two tables. 

1- Order (master table) having data

ORDERID    DATE             EMPNAME
1                   1-2-1999          JOHN
2                    1-1-2010         JOHN
3                     1-12-2011      FOAD

 2-Orderdetail (child table)  having data

PRID     PRNAME     SP   QTY   TOTAL   ORDERID
11          CD              5       10       50           1
11          CD              5        5         25          1
12           DVD           10      5         50           2          



i wan to get data like this

Empname        Prname     Qty     SP       total
JOHN               CD              15     5         75
                        DVD             5      10       50

Regards]]></description>
		<content:encoded><![CDATA[<p>Dear all i need a help from you people. I am using vb6 &amp; ms sql server2000. I have two tables. </p>
<p>1- Order (master table) having data</p>
<p>ORDERID    DATE             EMPNAME<br />
1                   1-2-1999          JOHN<br />
2                    1-1-2010         JOHN<br />
3                     1-12-2011      FOAD</p>
<p> 2-Orderdetail (child table)  having data</p>
<p>PRID     PRNAME     SP   QTY   TOTAL   ORDERID<br />
11          CD              5       10       50           1<br />
11          CD              5        5         25          1<br />
12           DVD           10      5         50           2          </p>
<p>i wan to get data like this</p>
<p>Empname        Prname     Qty     SP       total<br />
JOHN               CD              15     5         75<br />
                        DVD             5      10       50</p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Deepak Gakhar</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-164300</link>
		<dc:creator><![CDATA[Deepak Gakhar]]></dc:creator>
		<pubDate>Thu, 01 Sep 2011 12:43:19 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-164300</guid>
		<description><![CDATA[I need your help ragarding sql query.

Val_1, Val_2, Val_3,Val_4
a b c 1
a b c 2
a b c 4
m n o 1
m n o 2

and output should be

val_1, Val_2,val_3, val_4
a b c 1,2,4
m n o 1,2


Pls help if anyone know...]]></description>
		<content:encoded><![CDATA[<p>I need your help ragarding sql query.</p>
<p>Val_1, Val_2, Val_3,Val_4<br />
a b c 1<br />
a b c 2<br />
a b c 4<br />
m n o 1<br />
m n o 2</p>
<p>and output should be</p>
<p>val_1, Val_2,val_3, val_4<br />
a b c 1,2,4<br />
m n o 1,2</p>
<p>Pls help if anyone know&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Varun</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-141074</link>
		<dc:creator><![CDATA[Varun]]></dc:creator>
		<pubDate>Wed, 15 Jun 2011 12:45:34 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-141074</guid>
		<description><![CDATA[Hi Sally,

You can do the following to get the results inon estatement.

SELECT Col1,COUNT(*) AS Total FROM TMP
GROUP BY Col1
ORDER BY Col1]]></description>
		<content:encoded><![CDATA[<p>Hi Sally,</p>
<p>You can do the following to get the results inon estatement.</p>
<p>SELECT Col1,COUNT(*) AS Total FROM TMP<br />
GROUP BY Col1<br />
ORDER BY Col1</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Blueprint RSA</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-137724</link>
		<dc:creator><![CDATA[Blueprint RSA]]></dc:creator>
		<pubDate>Tue, 31 May 2011 04:03:50 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-137724</guid>
		<description><![CDATA[Thanks for posting this very informational blog.  Now I know the difference between DISTINCT and GROUP BY.  I hope to achieve something from what I learn today.]]></description>
		<content:encoded><![CDATA[<p>Thanks for posting this very informational blog.  Now I know the difference between DISTINCT and GROUP BY.  I hope to achieve something from what I learn today.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-132905</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 04 May 2011 14:55:35 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-132905</guid>
		<description><![CDATA[It should be

select company_name ,department_name from Department_Master where Status = ‘N’  group by company_name, order by company_name]]></description>
		<content:encoded><![CDATA[<p>It should be</p>
<p>select company_name ,department_name from Department_Master where Status = ‘N’  group by company_name, order by company_name</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: harsh shah</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-132512</link>
		<dc:creator><![CDATA[harsh shah]]></dc:creator>
		<pubDate>Mon, 02 May 2011 13:20:29 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-132512</guid>
		<description><![CDATA[this is my query and 

select company_name ,department_name from Department_Master where Status = &#039;N&#039; order by company_name, group by company_name

It shows me  this kind of the error 

Msg 156, Level 15, State 1, Line 1
Incorrect syntax near the keyword &#039;group&#039;.

What should i do to use the group by clouse in sql server 2008

Thanks in advance]]></description>
		<content:encoded><![CDATA[<p>this is my query and </p>
<p>select company_name ,department_name from Department_Master where Status = &#8216;N&#8217; order by company_name, group by company_name</p>
<p>It shows me  this kind of the error </p>
<p>Msg 156, Level 15, State 1, Line 1<br />
Incorrect syntax near the keyword &#8216;group&#8217;.</p>
<p>What should i do to use the group by clouse in sql server 2008</p>
<p>Thanks in advance</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pradeep Tiwari</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-131205</link>
		<dc:creator><![CDATA[pradeep Tiwari]]></dc:creator>
		<pubDate>Tue, 26 Apr 2011 07:38:45 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-131205</guid>
		<description><![CDATA[I guess something is missing in Article. Distinct creates a temp table and remove duplicates. Group by essentially does the same things, but it has additional overhead of sorting the records. By default group by is ASC sort. so Group by is slower in cases where the key grouping column is not indexed. If the query columns are already in clustered indexed, it may be same operation.
I would go with query plan and based on instincts will prefer Distinct over Group by]]></description>
		<content:encoded><![CDATA[<p>I guess something is missing in Article. Distinct creates a temp table and remove duplicates. Group by essentially does the same things, but it has additional overhead of sorting the records. By default group by is ASC sort. so Group by is slower in cases where the key grouping column is not indexed. If the query columns are already in clustered indexed, it may be same operation.<br />
I would go with query plan and based on instincts will prefer Distinct over Group by</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-125907</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Fri, 01 Apr 2011 06:02:10 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-125907</guid>
		<description><![CDATA[You cannot use distinct that way. What do you want to get? Post some sample data with expected result]]></description>
		<content:encoded><![CDATA[<p>You cannot use distinct that way. What do you want to get? Post some sample data with expected result</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Vicky Raj Sharma</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-125481</link>
		<dc:creator><![CDATA[Vicky Raj Sharma]]></dc:creator>
		<pubDate>Tue, 29 Mar 2011 07:41:55 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-125481</guid>
		<description><![CDATA[SELECT ROW_NUMBER() OVER (ORDER BY inserted_date DESC)
	AS Row, distinct product_type, parent_id,product_id,brand_id,device_id,p.subcategory_id,upc_code,sku,product_name,p.description,price,product_image,
	isDevice,dimension_length,dimension_length_unit,dimension_width,dimension_width_unit,
	dimension_height,dimension_height_unit,dimension_weight,dimension_weight_unit from tblProductDetails p join tblSubCategory s
	on p.subcategory_id=s.subcategory_id
	where parent_id=@cat_id and p.subcategory_id=@sub_id


My distinct keyword is having error.]]></description>
		<content:encoded><![CDATA[<p>SELECT ROW_NUMBER() OVER (ORDER BY inserted_date DESC)<br />
	AS Row, distinct product_type, parent_id,product_id,brand_id,device_id,p.subcategory_id,upc_code,sku,product_name,p.description,price,product_image,<br />
	isDevice,dimension_length,dimension_length_unit,dimension_width,dimension_width_unit,<br />
	dimension_height,dimension_height_unit,dimension_weight,dimension_weight_unit from tblProductDetails p join tblSubCategory s<br />
	on p.subcategory_id=s.subcategory_id<br />
	where parent_id=@cat_id and p.subcategory_id=@sub_id</p>
<p>My distinct keyword is having error.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: madhivanan</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-105949</link>
		<dc:creator><![CDATA[madhivanan]]></dc:creator>
		<pubDate>Wed, 15 Dec 2010 11:55:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-105949</guid>
		<description><![CDATA[Make sure to read this
http://beyondrelational.com/blogs/madhivanan/archive/2008/09/12/return-top-n-rows.aspx]]></description>
		<content:encoded><![CDATA[<p>Make sure to read this<br />
<a href="http://beyondrelational.com/blogs/madhivanan/archive/2008/09/12/return-top-n-rows.aspx" rel="nofollow">http://beyondrelational.com/blogs/madhivanan/archive/2008/09/12/return-top-n-rows.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: raj</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-105059</link>
		<dc:creator><![CDATA[raj]]></dc:creator>
		<pubDate>Mon, 13 Dec 2010 12:07:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-105059</guid>
		<description><![CDATA[Hi, 


i want to find distinct top.

top 3 for all UserId&#039;s.

for ex:

the table is as below:
 
Id UserId        Date
1     10     10/10/2010
1     10     10/10/2010
1       5     10/10/2010
1     10     10/10/2010
1       5     10/10/2010
1       7     10/10/2010
1     10     10/10/2010
1       5     10/10/2010
1     10     10/10/2010
1       5     10/10/2010

In the above table userid 10, 5 &amp; 7 has 5, 4 &amp; 1 rows respectively.

Now i expect 3 or below 3 from each user.

For Ex:

Id UserId Date
1     10     10/10/2010
1     10     10/10/2010
1     10     10/10/2010
1       5     10/10/2010
1       5     10/10/2010
1       5     10/10/2010
1       7     10/10/2010

how to solve this.


regards
rajendran]]></description>
		<content:encoded><![CDATA[<p>Hi, </p>
<p>i want to find distinct top.</p>
<p>top 3 for all UserId&#8217;s.</p>
<p>for ex:</p>
<p>the table is as below:</p>
<p>Id UserId        Date<br />
1     10     10/10/2010<br />
1     10     10/10/2010<br />
1       5     10/10/2010<br />
1     10     10/10/2010<br />
1       5     10/10/2010<br />
1       7     10/10/2010<br />
1     10     10/10/2010<br />
1       5     10/10/2010<br />
1     10     10/10/2010<br />
1       5     10/10/2010</p>
<p>In the above table userid 10, 5 &amp; 7 has 5, 4 &amp; 1 rows respectively.</p>
<p>Now i expect 3 or below 3 from each user.</p>
<p>For Ex:</p>
<p>Id UserId Date<br />
1     10     10/10/2010<br />
1     10     10/10/2010<br />
1     10     10/10/2010<br />
1       5     10/10/2010<br />
1       5     10/10/2010<br />
1       5     10/10/2010<br />
1       7     10/10/2010</p>
<p>how to solve this.</p>
<p>regards<br />
rajendran</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Manikandan</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-100500</link>
		<dc:creator><![CDATA[Manikandan]]></dc:creator>
		<pubDate>Wed, 17 Nov 2010 07:00:44 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-100500</guid>
		<description><![CDATA[Very nice...]]></description>
		<content:encoded><![CDATA[<p>Very nice&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: KUMAR</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-85081</link>
		<dc:creator><![CDATA[KUMAR]]></dc:creator>
		<pubDate>Tue, 24 Aug 2010 07:18:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-85081</guid>
		<description><![CDATA[Hi

why we should not use distinct and group by within the same sql statement or query??? any performance issue can u explain pls????????]]></description>
		<content:encoded><![CDATA[<p>Hi</p>
<p>why we should not use distinct and group by within the same sql statement or query??? any performance issue can u explain pls????????</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jazzy</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-85057</link>
		<dc:creator><![CDATA[jazzy]]></dc:creator>
		<pubDate>Tue, 24 Aug 2010 02:16:08 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-85057</guid>
		<description><![CDATA[I guess something is missing in Article. Distinct creates a temp table and remove duplicates. Group by essentially does the same things, but it has additional overhead of sorting the records. By default group by is ASC sort. so Group by is slower in cases where the key grouping column is not indexed. If the query columns are already in clustered indexed, it may be same operation.
I would go with query plan and based on instincts will prefer Distinct over Group by

thanks]]></description>
		<content:encoded><![CDATA[<p>I guess something is missing in Article. Distinct creates a temp table and remove duplicates. Group by essentially does the same things, but it has additional overhead of sorting the records. By default group by is ASC sort. so Group by is slower in cases where the key grouping column is not indexed. If the query columns are already in clustered indexed, it may be same operation.<br />
I would go with query plan and based on instincts will prefer Distinct over Group by</p>
<p>thanks</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Santhu</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-83988</link>
		<dc:creator><![CDATA[Santhu]]></dc:creator>
		<pubDate>Fri, 13 Aug 2010 15:22:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-83988</guid>
		<description><![CDATA[Hi All,
I have a db with fields Part number,supplier number and country name


I would like to  get a table with one unique record for partnumber and the country1 name country 2 name,--etc..
example this is what I have

partno   suno country
001        123  US
001         234  IN
001        567    AU
001        897   CA
002      235      IN
002       566     SR


etc...

I need a  table like this

part num country1  country 2 country 3 country 4
001           US           IN           AU          CA
002            IN            SR

etc...

Maximum  suppliers will be usually  from 1-10 ( Assumption)

Could anyone please help me out with the sql query to get this result.

.we may have  use do while loop,but  no clear idea

please hep me out..

Thanks,
Santhu]]></description>
		<content:encoded><![CDATA[<p>Hi All,<br />
I have a db with fields Part number,supplier number and country name</p>
<p>I would like to  get a table with one unique record for partnumber and the country1 name country 2 name,&#8211;etc..<br />
example this is what I have</p>
<p>partno   suno country<br />
001        123  US<br />
001         234  IN<br />
001        567    AU<br />
001        897   CA<br />
002      235      IN<br />
002       566     SR</p>
<p>etc&#8230;</p>
<p>I need a  table like this</p>
<p>part num country1  country 2 country 3 country 4<br />
001           US           IN           AU          CA<br />
002            IN            SR</p>
<p>etc&#8230;</p>
<p>Maximum  suppliers will be usually  from 1-10 ( Assumption)</p>
<p>Could anyone please help me out with the sql query to get this result.</p>
<p>.we may have  use do while loop,but  no clear idea</p>
<p>please hep me out..</p>
<p>Thanks,<br />
Santhu</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ram</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-79149</link>
		<dc:creator><![CDATA[Ram]]></dc:creator>
		<pubDate>Thu, 08 Jul 2010 01:49:24 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-79149</guid>
		<description><![CDATA[Hey Sally,

U can use above query  which gives the result that u expected

Thanks
Ram]]></description>
		<content:encoded><![CDATA[<p>Hey Sally,</p>
<p>U can use above query  which gives the result that u expected</p>
<p>Thanks<br />
Ram</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ram</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-79148</link>
		<dc:creator><![CDATA[Ram]]></dc:creator>
		<pubDate>Thu, 08 Jul 2010 01:48:11 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-79148</guid>
		<description><![CDATA[DECLARE @tmp TABLE(SrNo INT)

INSERT INTO @tmp VALUES(3)
INSERT INTO @tmp VALUES(3)
INSERT INTO @tmp VALUES(4)
INSERT INTO @tmp VALUES(5)
INSERT INTO @tmp VALUES(5)
INSERT INTO @tmp VALUES(5)
INSERT INTO @tmp VALUES(9)
INSERT INTO @tmp VALUES(8)
INSERT INTO @tmp VALUES(9)
INSERT INTO @tmp VALUES(9)
INSERT INTO @tmp VALUES(9)
INSERT INTO @tmp VALUES(9)

 
SELECT SrNo,COUNT(*) AS Total
FROM @tmp  group by SrNo]]></description>
		<content:encoded><![CDATA[<p>DECLARE @tmp TABLE(SrNo INT)</p>
<p>INSERT INTO @tmp VALUES(3)<br />
INSERT INTO @tmp VALUES(3)<br />
INSERT INTO @tmp VALUES(4)<br />
INSERT INTO @tmp VALUES(5)<br />
INSERT INTO @tmp VALUES(5)<br />
INSERT INTO @tmp VALUES(5)<br />
INSERT INTO @tmp VALUES(9)<br />
INSERT INTO @tmp VALUES(8)<br />
INSERT INTO @tmp VALUES(9)<br />
INSERT INTO @tmp VALUES(9)<br />
INSERT INTO @tmp VALUES(9)<br />
INSERT INTO @tmp VALUES(9)</p>
<p>SELECT SrNo,COUNT(*) AS Total<br />
FROM @tmp  group by SrNo</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-74014</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Mon, 31 May 2010 13:08:28 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-74014</guid>
		<description><![CDATA[@nahid

What should the result be?]]></description>
		<content:encoded><![CDATA[<p>@nahid</p>
<p>What should the result be?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lokesh</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-73779</link>
		<dc:creator><![CDATA[lokesh]]></dc:creator>
		<pubDate>Sat, 29 May 2010 13:14:23 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-73779</guid>
		<description><![CDATA[i have results like the following

Marea,Garea,SGarea
bck1,gitem1,sgitem1
bck1,gitem1,sgitem2
bck1,gitem1,sgitem3
bck2,gitem2,sgitem11
bck2,gitem2,sgitem12
bck2,gitem2,sgitem13

i require quey which should give result like below
(note:i wanted to show in a gridview like below)

bck1 gitem1 sgitem1
                    sgitem2
                    sgitem3
bck2 gitem2 sgitem11
                    sgitem12
                    sgitem13


can any one give me some idea.how i can make it possible.

from 
lokesh
]]></description>
		<content:encoded><![CDATA[<p>i have results like the following</p>
<p>Marea,Garea,SGarea<br />
bck1,gitem1,sgitem1<br />
bck1,gitem1,sgitem2<br />
bck1,gitem1,sgitem3<br />
bck2,gitem2,sgitem11<br />
bck2,gitem2,sgitem12<br />
bck2,gitem2,sgitem13</p>
<p>i require quey which should give result like below<br />
(note:i wanted to show in a gridview like below)</p>
<p>bck1 gitem1 sgitem1<br />
                    sgitem2<br />
                    sgitem3<br />
bck2 gitem2 sgitem11<br />
                    sgitem12<br />
                    sgitem13</p>
<p>can any one give me some idea.how i can make it possible.</p>
<p>from<br />
lokesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nahid</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-69857</link>
		<dc:creator><![CDATA[nahid]]></dc:creator>
		<pubDate>Sun, 09 May 2010 07:39:01 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-69857</guid>
		<description><![CDATA[Hi
I have a problem with join and group by
when I use group by in sub query the result will be done with 7 rows

SELECT  classNameId , max( viewCount) as viewcount
  FROM tagsasset
 group by classNameId

classNameId	viewcount
10011	             0
10020	             0
10040	             0
10056	             31
10066	             10
10067	            5409
10111	             2


 but when join it the result has 63 rows
because I put 2 condition
   when it was do 2 conditon for equal result show all of the row have this result

SELECT TA.title,TA.viewcount,TA.classnameid,c.value
from tagsasset TA inner join classname_ c
on c.classnameid=TA.classnameid
inner join
(SELECT  classNameId , max( viewCount) as viewcount
  FROM tagsasset
 group by classNameId )groupet on
  TA.viewcount=groupet.viewcount
 and
  groupet.classnameid=TA.classnameid
view  classnameid
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
0	10040
31	10056
10	10066
5409	10067
2	10111
2	10111


I have duplicate result
plz help me]]></description>
		<content:encoded><![CDATA[<p>Hi<br />
I have a problem with join and group by<br />
when I use group by in sub query the result will be done with 7 rows</p>
<p>SELECT  classNameId , max( viewCount) as viewcount<br />
  FROM tagsasset<br />
 group by classNameId</p>
<p>classNameId	viewcount<br />
10011	             0<br />
10020	             0<br />
10040	             0<br />
10056	             31<br />
10066	             10<br />
10067	            5409<br />
10111	             2</p>
<p> but when join it the result has 63 rows<br />
because I put 2 condition<br />
   when it was do 2 conditon for equal result show all of the row have this result</p>
<p>SELECT TA.title,TA.viewcount,TA.classnameid,c.value<br />
from tagsasset TA inner join classname_ c<br />
on c.classnameid=TA.classnameid<br />
inner join<br />
(SELECT  classNameId , max( viewCount) as viewcount<br />
  FROM tagsasset<br />
 group by classNameId )groupet on<br />
  TA.viewcount=groupet.viewcount<br />
 and<br />
  groupet.classnameid=TA.classnameid<br />
view  classnameid<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
0	10040<br />
31	10056<br />
10	10066<br />
5409	10067<br />
2	10111<br />
2	10111</p>
<p>I have duplicate result<br />
plz help me</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jignesh Shah</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-69614</link>
		<dc:creator><![CDATA[Jignesh Shah]]></dc:creator>
		<pubDate>Fri, 07 May 2010 05:03:58 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-69614</guid>
		<description><![CDATA[Thanks brian thanks a lot ! :-)

Sorry it was for lowest quantity...]]></description>
		<content:encoded><![CDATA[<p>Thanks brian thanks a lot ! :-)</p>
<p>Sorry it was for lowest quantity&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-69461</link>
		<dc:creator><![CDATA[Brian Tkatch]]></dc:creator>
		<pubDate>Thu, 06 May 2010 11:50:53 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-69461</guid>
		<description><![CDATA[@Jignesh

The lowest or the highest?

WITH
	Data(product, price, qty)
AS
	(
	 SELECT &#039;A&#039;, 10, 5 UNION ALL
	 SELECT &#039;A&#039;, 20, 2 UNION ALL
	 SELECT &#039;A&#039;, 30, 1 UNION ALL
	 SELECT &#039;B&#039;, 20, 3 UNION ALL
	 SELECT &#039;B&#039;, 10, 7
	),
	Data_RN
AS
	(
	 SELECT
			product,
			price,
			qty,
			ROW_NUMBER() OVER(PARTITION BY Product ORDER BY qty DESC) RN
	 FROM
			Data
	)
SELECT
		product,
		price * qty
FROM
		Data_RN
WHERE
		RN = 1;]]></description>
		<content:encoded><![CDATA[<p>@Jignesh</p>
<p>The lowest or the highest?</p>
<p>WITH<br />
	Data(product, price, qty)<br />
AS<br />
	(<br />
	 SELECT &#8216;A&#8217;, 10, 5 UNION ALL<br />
	 SELECT &#8216;A&#8217;, 20, 2 UNION ALL<br />
	 SELECT &#8216;A&#8217;, 30, 1 UNION ALL<br />
	 SELECT &#8216;B&#8217;, 20, 3 UNION ALL<br />
	 SELECT &#8216;B&#8217;, 10, 7<br />
	),<br />
	Data_RN<br />
AS<br />
	(<br />
	 SELECT<br />
			product,<br />
			price,<br />
			qty,<br />
			ROW_NUMBER() OVER(PARTITION BY Product ORDER BY qty DESC) RN<br />
	 FROM<br />
			Data<br />
	)<br />
SELECT<br />
		product,<br />
		price * qty<br />
FROM<br />
		Data_RN<br />
WHERE<br />
		RN = 1;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jignesh Shah</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-69245</link>
		<dc:creator><![CDATA[Jignesh Shah]]></dc:creator>
		<pubDate>Wed, 05 May 2010 10:41:49 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-69245</guid>
		<description><![CDATA[Hi,

I have the following data in the table.

product price	 qty
====================
A	 10	          5
A	 20	          2
A	 30	          1
B       20             3
B       10             7

The result that i expect from SQL query  
basically the total = sum (price x qty) but quantity should be the lowest among same product

for product A is
LINETOTAL
50

for product B is
SUMTOTAL
70


Could you please help me how to write the SQL query.

Thanks,
Jignesh]]></description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>I have the following data in the table.</p>
<p>product price	 qty<br />
====================<br />
A	 10	          5<br />
A	 20	          2<br />
A	 30	          1<br />
B       20             3<br />
B       10             7</p>
<p>The result that i expect from SQL query<br />
basically the total = sum (price x qty) but quantity should be the lowest among same product</p>
<p>for product A is<br />
LINETOTAL<br />
50</p>
<p>for product B is<br />
SUMTOTAL<br />
70</p>
<p>Could you please help me how to write the SQL query.</p>
<p>Thanks,<br />
Jignesh</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: RSA Online</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-68605</link>
		<dc:creator><![CDATA[RSA Online]]></dc:creator>
		<pubDate>Mon, 03 May 2010 13:18:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-68605</guid>
		<description><![CDATA[I&#039;ll use DISTINCT as it is the true meaning of what I want to achieve... I had just heard in the past that GROUP BY was a lot more performant, but like you say it should execute the same query plan - and I can always check that too!

So thanks, I am now not as &quot;anti-DISTINCT&quot; as I was before I read your post. ;-)

Cheers.]]></description>
		<content:encoded><![CDATA[<p>I&#8217;ll use DISTINCT as it is the true meaning of what I want to achieve&#8230; I had just heard in the past that GROUP BY was a lot more performant, but like you say it should execute the same query plan &#8211; and I can always check that too!</p>
<p>So thanks, I am now not as &#8220;anti-DISTINCT&#8221; as I was before I read your post. ;-)</p>
<p>Cheers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sally</title>
		<link>http://blog.sqlauthority.com/2007/03/29/sql-server-difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-67433</link>
		<dc:creator><![CDATA[sally]]></dc:creator>
		<pubDate>Wed, 28 Apr 2010 13:52:31 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/2007/03/29/difference-between-distinct-and-group-by-distinct-vs-group-by/#comment-67433</guid>
		<description><![CDATA[HI, i am new to OLAP in Sql Server 2005, bascially  i have read through lots of article on this OLAP and basically i get to know how it works and function theorically, but i could not find an article to show me step by step on how to create the cube and how to query the data from the cube. Would very much appreciated if somebody out there can explain to me in details how to i create cube from sql server 2005 as i totally no idea at all. Though i can view the sample cude in sql server 2005, but i dunno how to create it from my relational database. I need it very urgent as needed by my job functionality. Hope to get some explanation from you guys asap. Just assume i am totally new and please guide me step by step to create a normal and simple cube and query from the cube. I just need to create simple prototype. Thanks alot yea guys :)]]></description>
		<content:encoded><![CDATA[<p>HI, i am new to OLAP in Sql Server 2005, bascially  i have read through lots of article on this OLAP and basically i get to know how it works and function theorically, but i could not find an article to show me step by step on how to create the cube and how to query the data from the cube. Would very much appreciated if somebody out there can explain to me in details how to i create cube from sql server 2005 as i totally no idea at all. Though i can view the sample cude in sql server 2005, but i dunno how to create it from my relational database. I need it very urgent as needed by my job functionality. Hope to get some explanation from you guys asap. Just assume i am totally new and please guide me step by step to create a normal and simple cube and query from the cube. I just need to create simple prototype. Thanks alot yea guys :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

