You are here: Re: Get only Max of each distinct? « MsSQL Server « IT news, forums, messages
Re: Get only Max of each distinct?

Posted by sunilkes on 11/07/07 11:35

On Nov 7, 10:10 am, Ed Murphy <emurph...@socal.rr.com> wrote:
> sunil...@gmail.com wrote:
> > I have a table
>
> > ItemID Version
>
> > 12 1.0
> > 12 1.1
> > 12 2.0
> > 13 2.0
> > 13 1.0
> > 14 1.0
> > 15 1.0
> > 15 5.0
>
> I assume 5.0 is a typo for 2.0
>
Got it, actually it was pretty simple, was trying it incorrectly
earlier !

SELECT MAX(Version_Number) AS Maxim, ItemId
FROM tblItems
GROUP BY ItemId

Thanks

> > 15 2.1

>
> > How do I write a Select query to get me all distinct item IDs, whichm
> > are of the latest version?
>
> > Like this:
>
> > ItemID Version
> > 12 2.0
> > 13 2.0
> > 14 1.0
> > 15 2.1
>
> This smells like homework. Look up MAX() and GROUP BY.

 

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

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