Re: Newbie SQL question (Top 10 values)

From: Reinhard Kuhn <kuhn_at_cas-ps.com>
Date: 1996/01/25
Message-ID: <4e7rjk$qd1_at_fred.cas-ps.com>#1/1


In article <Pine.SUN.3.91.960116101414.20843D-100000_at_seatimes>, sbut-is_at_seatimes.com says...
>
>
>On Mon, 15 Jan 1996, RAC wrote:
>
>rownum is checked prior to the sort. This solution will select the first
>10 rows found, then sort those into descending order. You will need to
>do this in two passes. First pass is to create a view that sorts the
>rows into the order you want. The second pass is to select the first 10
>rows from that view.
>

This won't do it either.

 You can't use 'order by' in a view definition (or a subquery).  A view is not stored as a kind of 'temporary table' but as  a simple string representing a fragment of a sql query.  Whenever you select from a view, this fragment will be merged syntactically  with the query and the resulting query will be sent to the parser.  So you can't get anything from a view that you won't get with a query.

-- 
    _/_/_/   _/_/_/ _/    _/  // Reinhard Kuhn             /  It can be      
   _/    _/ _/     _/  _/    //         (kuhn_at_cas-ps.com) /  done quickly,   
  _/_/_/   _/_/_/ _/_/      // CAS GmbH                  /  cheaply or well  
 _/  _/   _/     _/  _/    // Lemberger Strasse 14      /   - pick any two!  
_/   _/  _/_/_/ _/    _/  // 66955 Pirmasens, Germany  /   
                                   
Received on Thu Jan 25 1996 - 00:00:00 CET

Original text of this message