JAN NUMBER(5),
FEB NUMBER(5),
MAR NUMBER(5),
APR NUMBER(5),
MAY NUMBER(5),
JUN NUMBER(5),
JULY NUMBER(5),
AUG NUMBER(5),
SEP NUMBER(5),
OCT NUMBER(5),
NOV NUMBER(5),
DECE NUMBER(5)table中的某些字段
字段名是12个月英文缩写,每个月都会存储相应的data现在我想根据sysdate,查询出当月,下俩个月的data怎么写会简洁一些
我想的是:select case to_char(sysdate,'mm') when '01' then JAN
when '02' then FEB
...
end month1,
case to_char(sysdate,'mm')+1 when '01' then JAN
when '02' then FEB
...
end month2,
...
SQL> select to_char(add_months(sysdate,1),'mm') from dual;
TO_CHAR(ADD_MONTHS(SYSDATE,1),
------------------------------
07
select case to_char(add_months(sysdate,1),'mm')
when '01' then jan
when '02' then feb
when '03' then mar
...
else null
end month1
from ...
select case to_char(add_months(sysdate, 0), 'mm')
when '01' then
Jan
when '02' then
Feb
when '03' then
MAR
when '04' then
APR
when '05' then
MAY
when '06' then
JUN
when '07' then
JULY
when '08' then
AUG
when '10' then
OCT
when '11' then
NOV
when '12' then
DECE
end month1,
case to_char(add_months(sysdate, 1), 'mm')
when '01' then
Jan
when '02' then
Feb
when '03' then
MAR
when '04' then
APR
when '05' then
MAY
when '06' then
JUN
when '07' then
JULY
when '08' then
AUG
when '10' then
OCT
when '11' then
NOV
when '12' then
DECE
end month2,
case to_char(add_months(sysdate, 2), 'mm')
when '01' then
Jan
when '02' then
Feb
when '03' then
MAR
when '04' then
APR
when '05' then
MAY
when '06' then
JUN
when '07' then
JULY
when '08' then
AUG
when '10' then
OCT
when '11' then
NOV
when '12' then
DECE
end month3
from table t
这样写??感觉好冗长阿
window 中set NLS_LANG=american_america.AL32UTF8
linux 中export NLS_LANG=american_america.AL32UTF8
改过之后进行sqlplus ,然后就SQL> select to_char(sysdate,'MON') from dual;TO_CHAR(SYSDATE,'M
------------------
JUN可以得到你想要的了。。
再下面的就空间实现 了。。
A 1 2
B
C