Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Why doesn't this work?
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
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