Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Query to provide range of repeat values
Slight variation on the previous solution:
select min(year) first_year, max(year) last_year, cost from (
select year, cost, max(rn) over (partition by cost order by year) rn
from
(
select year,
cost, case when year - lag(year) over (order by cost, year) != 1 then row_number() over (order by cost) when row_number() over (order by cost) = 1 then 1 end rn
VC Received on Thu Feb 19 2004 - 20:48:16 CST
![]() |
![]() |