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: Groups of Groups?

Re: Groups of Groups?

From: Thorsten Kettner <thorsten.kettner_at_web.de>
Date: 6 Feb 2003 23:20:17 -0800
Message-ID: <74a9c367.0302062320.491b1831@posting.google.com>


Rene Nyffenegger <rene.nyffenegger_at_gmx.ch> wrote in message news:<b1u8s7$166n38$1_at_ID-82536.news.dfncis.de>...
> select id, start_date from (
> select
> id,
> max(start_date) over() start_date,
> rank() over (order by length(prefix) desc, start_date desc) r
> from
> prefix_
> where
> sysdate between start_date and end_date and
> substr('1234501234',1,length(prefix)) = prefix
> )
> where r = 1;

Wow! I am working with Ansi-SQL89 still (Oracle 7) :( and didn't know of all the new functions that meanwhile exist. I have learned a great deal from your post. However shouldn't it be:

   select

     id, 
     start_date, ...

instead of

   select

     id, 
     max(start_date) over() start_date, ...

What would the max function be good for? Don't you already take the start_date into account in your ranking clause? With max you are taking the maximum of all start dates instead of taking the start date of the best record. Received on Fri Feb 07 2003 - 01:20:17 CST

Original text of this message

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