| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
|  |  | |||
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL Query with DISTINCT
On 2006-01-13, Jonathan Lewis <jonathan_at_jlcomp.demon.co.uk> wrote:
> When you say it returns the most recent row,
> is this because you are using validita to identify
> the most recent row, and have an "order by desc"
> on that column ?
exactly ...
> If so, then you need to look at Oracle's analytic functions
> to do the same sort of thing - something like
>
> select
>     *
> from (
>     select
>         descr,validita,imp,rif_calcolo,
>         row_number() over (
>             partition by rif_calcolo order by validita desc
>         ) row_num
>     from indennita
>     where societa=1
>     and qualifica=3
>     and validita<= to_date('1/1/2006','dd/mm/yyyy')
> )
> where row_num = 1
> ;
tanks a lot for your help ... I'm going to study ;-))
bye ...
-- 
#include <stdio.h>
int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
116,46,105,116,62,10,10,0};printf("%s",c);return 0;}
Received on Fri Jan 13 2006 - 03:58:31 CST
|  |  |