0

Am trying to add a constant column to the select query which is quering an inner query.
Need your help with the query.

select *,'1' as flag from
(
    select ROW_NUMBER() OVER (PARTITION BY e_id ORDER BY birth_date DESC) as rn,wh.birth_date,e.*,
    xy.m_id from employee e 
                    inner join table2 xy on e.e_id=xy.employee_id
                    inner join table3 wc on e.e_id=wc.e_id 
                    left outer join  table4 wh on xy.e_id=wh.e_id 
        where  my_id='1234' 
 ) where rn=1;

The above query is throwing an error - ORA-00923: FROM keyword not found where expected
00923. 00000 - "FROM keyword not found where expected"

But when I change the query as following (not changing the inner query) it works fine.

select '1' as flag ,birth_date,e_id,[some othe columns from the below tables] from
(
    select ROW_NUMBER() OVER (PARTITION BY e_id ORDER BY birth_date DESC) as rn,wh.birth_date,e.*,
    xy.m_id from employee e 
                    inner join table2 xy on e.e_id=xy.employee_id
                    inner join table3 wc on e.e_id=wc.e_id 
                    left outer join  table4 wh on xy.e_id=wh.e_id 
        where  my_id='1234' 
 ) where rn=1;

Is it not possible to add a constant column when quering all the columns, I mean when using * ?

Appriciate your help. Thanks :)

2
Contributors
1
Reply
10
Views
4 Years
Discussion Span
Last Post by rubberman
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.