RE: sql question

  • From: "Rudy Zung" <rudy.zung@xxxxxxxxxxxxxxx>
  • To: "oracle-l" <Oracle-L@xxxxxxxxxxxxx>
  • Date: Mon, 24 Apr 2006 14:55:48 -0400

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@xxxxxxxxxxxxx
[mailto:oracle-l-bounce@xxxxxxxxxxxxx] 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@xxxxxxxxxxxxx> 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
> > --
> > //www.freelists.org/webpage/oracle-l
> >
> >
> >
>
> --
> Mladen Gogala
> http://www.mgogala.com
>
>
--
//www.freelists.org/webpage/oracle-l


--
//www.freelists.org/webpage/oracle-l


Other related posts: