添加列以选择*

时间:2011-11-03 11:14:27

标签: 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
from WEIGHTED_AVERAGE w1

然而,Oracle中的以下内容导致“找不到ORA-00923 FROM关键字”:

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 end_date_modified
from WEIGHTED_AVERAGE w1

我已经搜索了所有内容,但无法弄清楚如何在Oracle中实现这一目标。

2 个答案:

答案 0 :(得分:4)

试试这个

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

答案 1 :(得分:1)

将SELECT的开头修改为w1。*