You are here: Re: How top actually works « MsSQL Server « IT news, forums, messages
Re: How top actually works

Posted by Gints Plivna on 01/24/08 10:25

On 24 Janv., 01:17, Erland Sommarskog <esq...@sommarskog.se> wrote:
> Gints Plivna (gints.pli...@gmail.com) writes:
> > I'm quite sure row_number won't help me in this case, because I'd like
> > to limit found number of rows. row_number actually must have order by
> > clause and ordering before limiting returned number of rows is the
> > thing I'd like to avoid.
>
> That can be achieved with row_number with some trickery. Consider:
>
>    with numbered AS (
>    select *, rn = row_number() OVER (order by x)
>    from   (SELECT *, x = 'x' FROM Orders) as s
>    )
>    SELECT * FROM numbered WHERE rn < 20
>    ORDER BY CustomerID

Ahh that's real trickery! :)
OK I'll remember it just in case in the future I'll need something
like that!
Thanks!

Gints

 

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

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