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: how to retrieve fields & tables with name ending with YYYYMM

Re: how to retrieve fields & tables with name ending with YYYYMM

From: Malcolm Dew-Jones <yf110_at_vtn1.victoria.tc.ca>
Date: 17 Dec 99 22:31:52 GMT
Message-ID: <385ab9d8.0@news.victoria.tc.ca>


lai (lyekheng_at_hotmail.com) wrote:
: Hi,

: I have fields and tables with name ending with YYYYMM, e.g.
: gross_amount_YYYYMM field, trfc_YYYY_YYYY table. If the current year is
: 1999 and month is March, then the data would extract gross_amount_199903
: field from trfc_1998_1999 table. Is there a way to do that?

...an example...

create or replace view ALL_TRFC as
select gross_amount_199903 gross_amount,

       '199903' yyyymm
from trfc_1998_1999
union all
select gross_amount_199904 gross_amount,

       '199904' yyyymm
from trfc_1998_1999
union all
select gross_amount_199905 gross_amount,

       '199905' yyyymm
from trfc_1998_1999
;

now we can use SQL such as

  select * from ALL_TRFC where yyyymm between '199902' and '199903';

Each year add the new year's table into the view definition and rebuild the view.

You may wish to build some indexes on the trfc_yyyy_yyyy tables. Received on Fri Dec 17 1999 - 16:31:52 CST

Original text of this message

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