Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: sql question
select year
from (select century.d * 100 +
ten.d * 10 + one.d year from (select 0 d from dual union select 1 from dual union select 2 from dual union select 3 from dual union select 4 from dual union select 5 from dual union select 6 from dual union select 7 from dual union select 8 from dual union select 9 from dual) one, (select 0 d from dual union select 1 from dual union select 2 from dual union select 3 from dual union select 4 from dual union select 5 from dual union select 6 from dual union select 7 from dual union select 8 from dual union select 9 from dual) ten, (select 19 d from dual union select 20 from dual) century) where year between 1995 and to_number(to_char(sysdate, 'yyyy'))order by year
...Rudy
-----Original Message-----
From: oracle-l-bounce_at_freelists.org
[mailto:oracle-l-bounce_at_freelists.org] On Behalf Of Chris Stephens
Sent: Friday, April 21, 2006 8:54 AM
To: Mladen Gogala
Cc: oracle-l
Subject: Re: sql question
yeah...that works this year. the whole point is to not have to maintain a list of years up to the current year to infinity and beyond.
On 4/20/06, Mladen Gogala <gogala_at_sbcglobal.net> wrote:
> select '1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005, 2006' from dual;
>
> On 04/20/2006 04:40:44 PM, Chris Stephens wrote:
> > Can anyone think of a way to generate a list of years from say 1995
to
> > the current year in straight sql?
> >
> >
> > chris
> > --
> > http://www.freelists.org/webpage/oracle-l
> >
> >
> >
>
> --
> Mladen Gogala
> http://www.mgogala.com
>
>
-- http://www.freelists.org/webpage/oracle-l -- http://www.freelists.org/webpage/oracle-lReceived on Mon Apr 24 2006 - 13:55:48 CDT