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

Posted by Jeff Kish on 06/21/06 01:51

On Tue, 20 Jun 2006 22:04:41 +0000 (UTC), Erland Sommarskog
<esquel@sommarskog.se> wrote:

>Jeff Kish (kishjjrjj@charter.net) writes:
>> How would I add the attribute column so I know exactly which ones are
>> of interest? That was what is the most difficult thing for me to
>> figure out.
>
>Not sure that I understood your original question, but try:
>
> SELECT a.object, a.attribute, a.keyseq
> FROM metatable a
> JOIN (SELECT object, keyseq
> FROM metatable
> WHERE keyseq IS NOT NULL
> GROUP BY object, keyseq
> HAVING COUNT(*) > 1) AS b ON a.object = b.object
> AND a.keyseq = b.keyseq
>
>The thing in parenthesis is a derived table. You could think of a
>derived table as a temp table within the query, but never materialised.
>Or even computed, the optimizer may recasts the computation order
>to get performance. This is a great tool to write complex queries
>effeciently.
>
>And, yes, this is ANSI-SQL that should run on most RDBMS. (It's not
>as vintage as HAVING though.)
Wow.
I'll have to study up some more on the 'ON' and 'AS' syntax.

Thanks so much Erland.

I appreciate both the answer and the education.
kind regards

 

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

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