Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Why doesn't this work?

Re: Why doesn't this work?

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: Sun, 13 Dec 1998 14:52:46 GMT
Message-ID: <367dd461.10535379@192.86.155.100>


A copy of this was sent to PMG <pete_g_at_2xtreme.net> (if that email address didn't require changing) On Sun, 13 Dec 1998 06:35:33 GMT, you wrote:

>This query works in SQLPlus:
>
>select name, count(name)
>from emp
>group by name
>order by count(name) desc;
>
>But why doesn't this work:
>
>create view v as
>select name, count(name)
>from emp
>group by name
>order by count(name) desc;
>
>I thought views were just stored queries. So if the first one works why
>doesn't the second work?

views are not just stored queries. A view is much more like a database table then a stored query. Since tables and relational sets in general, do not have ORDER, order by not only doesn't make sense on them -- it is not allowed in the language.

In order for a client applicatoin using a SELECT to be gauranteed to get the data in sorted order -- that application must apply the order by clause.  

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Service Industries
Reston, VA USA

--
http://govt.us.oracle.com/ -- downloadable utilities  



Opinions are mine and do not necessarily reflect those of Oracle Corporation  

Anti-Anti Spam Msg: if you want an answer emailed to you, you have to make it easy to get email to you. Any bounced email will be treated the same way i treat SPAM-- I delete it. Received on Sun Dec 13 1998 - 08:52:46 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US