求Oracle创建视图相关语句
通过表创建视图,想让视图里面其中一个列数据=a时,让其=b,数据=c时,让其=d。我用的case..when。但是执行不成功,
代码如下create or replace view yuebaoheji as
select SUBSTR(iufo_measure_pubdata.time_code,1,4) as kjnd, SUBSTR(iufo_measure_pubdata.time_code,1,4)||SUBSTR(iufo_measure_pubdata.time_code,9,2) as kjqj,
case when (iufo_unit_info.unit_id='37000011') then iufo_unit_info.unit_id='37000111',
iufo_unit_info.unit_name , iufo_measure_data_duz9rms7.m10001 as hejishouru, iufo_measure_data_duz9rms7.m10002 ,
iufo_measure_data_duz9rms7.m10006 , iufo_measure_data_duz9rms7.m10010 , iufo_measure_data_duz9rms7.m10011 ,
iufo_measure_data_duz9rms7.m10013 as qyqtxjcz, iufo_measure_data_duz9rms7.m10015 , iufo_measure_data_duz9rms7.m10019 ,
iufo_measure_data_duz9rms7.m10020 , iufo_measure_data_duz9rms7.m10022 , iufo_measure_data_duz9rms7.m10023 ,
iufo_measure_data_duz9rms7.m10027 , iufo_measure_data_duz9rms7.m10028 , iufo_measure_data_duz9rms7.m10030 ,
iufo_measure_data_duz9rms7.m10032 , iufo_measure_data_duz9rms7.m10036 , iufo_measure_data_duz9rms7.m10037 ,
iufo_measure_data_duz9rms7.m10039 , iufo_measure_data_duz9rms7.m10041 , iufo_measure_data_duz9rms7.m10045 ,
iufo_measure_data_duz9rms7.m10046 , iufo_measure_data_duz9rms7.m10048 , iufo_measure_data_duz9rms7.m10049 ,
iufo_measure_data_duz9rms7.m10053 , iufo_measure_data_duz9rms7.m10054 , iufo_measure_data_duz9rms7.m10230 ,
iufo_measure_data_duz9rms7.m10056 , iufo_measure_data_duz9rms7.m10060 , iufo_measure_data_duz9rms7.m10061 ,
iufo_measure_data_duz9rms7.m10063 , iufo_measure_data_duz9rms7.m10065 , iufo_measure_data_duz9rms7.m10069 ,
iufo_measure_data_duz9rms7.m10070 , iufo_measure_data_duz9rms7.m10071 , iufo_measure_data_duz9rms7.m10073 ,
iufo_measure_data_duz9rms7.m10077 , iufo_measure_data_duz9rms7.m10078 , iufo_measure_data_duz9rms7.m10079 ,
iufo_measure_data_duz9rms7.m10081 , iufo_measure_data_6urszruw.m10001 , iufo_measure_data_6urszruw.m10013
from iufo_unit_info,iufo_measure_data_6urszruw,iufo_measure_pubdata,iufo_measure_data_duz9rms7
where iufo_measure_data_6urszruw.alone_id = iufo_measure_pubdata.alone_id
and iufo_measure_data_duz9rms7.alone_id = iufo_measure_pubdata.alone_id
and iufo_measure_data_6urszruw.line_no = iufo_measure_data_duz9rms7.line_no and iufo_unit_info.unit_id = iufo_measure_pubdata.code
and (iufo_unit_info.level_code like 'i%' )
and iufo_measure_pubdata.ver=0 and iufo_measure_pubdata.formula_id is null;][/code]
------解决思路----------------------
引用:case when (iufo_unit_info.unit_id='37000011') then iufo_unit_info.unit_id='37000111',,除了我写的这句case。。when,不对,其他可以正常执行
create or replace view yuebaoheji as
select SUBSTR(iufo_measure_pubdata.time_code, 1, 4) as kjnd,
SUBSTR(iufo_measure_pubdata.time_code, 1, 4)
------解决思路----------------------
SUBSTR(iufo_measure_pubdata.time_code, 9, 2) as kjqj,
case
when (iufo_unit_info.unit_id = '37000011') then
'37000111'
ELSE
iufo_unit_info.unit_id
END unit_id,
iufo_unit_info.unit_name,
iufo_measure_data_duz9rms7.m10001 as hejishouru,
iufo_measure_data_duz9rms7.m10002,
iufo_measure_data_duz9rms7.m10006,
iufo_measure_data_duz9rms7.m10010,
iufo_measure_data_duz9rms7.m10011,
iufo_measure_data_duz9rms7.m10013 as qyqtxjcz,
iufo_measure_data_duz9rms7.m10015,
iufo_measure_data_duz9rms7.m10019,
iufo_measure_data_duz9rms7.m10020,
iufo_measure_data_duz9rms7.m10022,