Sql 添加要选择的列*
在SQL Server中,我曾经这样做,向select添加额外的列:Sql 添加要选择的列*,sql,sql-server,oracle,Sql,Sql Server,Oracle,在SQL Server中,我曾经这样做,向select添加额外的列: select *, case when w1.start_date < w2.start_date then to_date(w2.START_date, 'DD/MM/YYYY') - 1 else to_date(w1.end_date, 'DD/MM/YYYY') end as end_date_modified
select *,
case
when w1.start_date < w2.start_date then
to_date(w2.START_date, 'DD/MM/YYYY') - 1
else
to_date(w1.end_date, 'DD/MM/YYYY')
end as end_date_modified
from WEIGHTED_AVERAGE w1
选择*,
案例
当w1.开始日期
但Oracle中的以下内容导致“ORA-00923 FROM关键字未在预期位置找到”:
选择*,
案例
当w1.开始日期
我已经搜索了所有地方,但不知道如何在Oracle中实现这一点。试试这个
select w1.*,
case
when w1.start_date < w2.start_date then
to_date(w2.START_date, 'DD/MM/YYYY') - 1
else
to_date(w1.end_date, 'DD/MM/YYYY')
end end_date_modified
from WEIGHTED_AVERAGE w1
选择w1.*,
案例
当w1.开始日期
将SELECT的开头改为w1.*也要考虑,不要使用*,这可能会花费更多的时间,但如果列发生更改,或随着表的增长减少传输的数据量,这将有助于在以后提供更好的错误消息。@vitorfs-正是我想要的,谢谢。你的第一个答案是:-)
select w1.*,
case
when w1.start_date < w2.start_date then
to_date(w2.START_date, 'DD/MM/YYYY') - 1
else
to_date(w1.end_date, 'DD/MM/YYYY')
end end_date_modified
from WEIGHTED_AVERAGE w1