You are here: Re: Select distinct rows from duplicate rows.... « MsSQL Server « IT news, forums, messages
Re: Select distinct rows from duplicate rows....

Posted by SQL Menace on 11/28/07 13:50

SELECT Name, MAX(Weight) AS Weight
FROM Customer
GROUP BY Name

or

SELECT Name, MIN(Weight) AS Weight
FROM Customer
GROUP BY Name

Denis The SQL Menace
http://sqlservercode.blogspot.com
http://sqlblog.com/blogs/denis_gobo/default.aspx



On Nov 28, 8:26 am, sanjeev.atvan...@gmail.com wrote:
> Dear Gurus,
>
> I have table with following entries
>
> Table name = Customer
>
> Name Weight
> ------------ -----------
> Sanjeev 85
> Sanjeev 75
> Rajeev 80
> Rajeev 45
> Sandy 35
> Sandy 30
> Harry 15
> Harry 45
>
> I need a output as follow
>
> Name Weight
> ------------ -----------
> Sanjeev 85
> Rajeev 80
> Sandy 30
> Harry 45
>
> OR
>
> Name Weight
> ------------ -----------
> Sanjeev 75
> Rajeev 45
> Sandy 35
> Harry 15
>
> i.e. only distinct Name should display with only one value of Weight.
> I tried with 'group by' on Name column but it shows me all rows.
>
> Could anyone help me for above.
>
> Thanking in Advance.
>
> Regards
> Sanjeev
> sanjeev.atvan...@gmail.com

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация