Skip to content
Advertisement

SQL Developer duplicate column name while creating view

I am getting this error while running statement specified below

ORA-00957: duplicate column name
00957. 00000 – “duplicate column name”

My query:

create view vw_sales_may 
as 
    select 
        customers.id, orderdetails.id, sales.sale_date, sales.total_value 
    from 
        customers 
    inner join 
        sales on customers.id = sales.customer_id 
    join 
        orderdetails on orderdetails.customer_id = customers.id 
    where 
        to_char(sale_date, 'MM') = 05;

Advertisement

Answer

Just need to add column aliases.

create view vw_sales_may as 
select customers.id as CustomerID, 
orderdetails.id as OrderDetailsID, 
sales.sale_date, 
sales.total_value 
from customers 
inner join sales on customers.id = sales.customer_id 
join orderdetails on orderdetails.customer_id = customers.id 
where to_char(sale_date,'MM') = 05;
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement