You are here: Re: How to do an equivelent First() operation « MsSQL Server « IT news, forums, messages
Re: How to do an equivelent First() operation

Posted by David Portas on 05/04/06 00:39

rss@ddsc.com wrote:
> set rowcount 1
> select Idnum1,Idnum3 from mytable order by Idnum1 DESC, idnum3 ASC
>
> is equivelent to
> select first(Idnum1),first(idnum3) from mytable order by first(Idnum1)
> DESC ,first(Idnum3) ASC
>
>
> Isn't that silly? why did Microsoft not add an agregate function First
> for the Microsoft SQL Server to be consistent with its Microsoft Access
> product eh?

RANK() and ROW_NUMBER() are much more powerful alternatives. FIRST is
not a proper aggregate function, even in Access. RANK() and
ROW_NUMBER() are also ANSI-standard SQL functions. One would hope that
ANSI compatibility is a higher priority for inclusion than replicating
the peculiar quirks of Access.

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--

 

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

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