You are here: Re: group by « MsSQL Server « IT news, forums, messages
Re: group by

Posted by Erland Sommarskog on 06/19/06 21:58

Jeff Kish (jeff.kish@mro.com) writes:
> Some helpful person (thanks m cadot) in the Oracle group gave me some
> guidance and made an initial suggestion which I show here, and a more
> advanced solution I'm not showing because I don't understand it, and it
> might be oracle specific.
>
> select object, keyseq, count(keyseq)
> from metatable
> where keyseq is not null
> group by object, keyseq
> having count(*) > 1 ---<----- just this line to add
> order by count(keyseq)

It can't be any more standard SQL than this. The above SELECT should
run on any RDBMS that supports SQL.

HAVING is like WHERE, but is applied after the GROUP BY, and thus
permits filters with aggregate functions.

--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

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

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