在oracle中如果列在sql中操作,是很正常的事,比如:
select col1,col2,col1+col2 from table1;
但如果使用了別名,情況就不同了:
select col1 a,col2 b,a+b from table1;
會報以下的錯誤:
ORA-00904: "B": invalid identifier
怎么解決呢,就是套一個select在外面:
select a,b,a+b from (select col1 a,col2 b from table1);
這樣就沒有問題了。
我的微博
http://t.sina.com.cn/1401900445