You are here: Re: ORDER BY in VIEW not working « MsSQL Server « IT news, forums, messages
Re: ORDER BY in VIEW not working

Posted by Serge Rielau on 03/07/06 23:16

Rick,

I don't get your logic forcing the extra view.

Example:
CREATE TABLE T(c1);
CREATE VIEW V AS SELECT * FROM T ORDER BY c1 ASC;

-- I don't care:
SELECT * FROM V => no order

-- I want "the" order:
SELECT * FROM V ORDER BY ORDER OF V => C1 ASCENDING
Note that the clause is rather brain dead. Your .NET/JDBC/PHP client
could tack it on under the covers if you always want it.

-- I want order and I'm going to decide what it is:
SELECT * FROM V ORDER BY c1 DESC => c1 DESCENDING

The problem with your statement level switch is that it is - eh -
statement level.
That is what if you have a nested view somewhere embedded.
You probably don't want the DBMS to sort unless the order finds it's way
to the top.

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

 

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

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