Search code examples
sqloracleoracle11gora-00918

Why does it say column ambiguously defined?


select a.id_progdi, a.nama_progdi, avg(b.ipk)  
from tb_ipk b 
join tb_mahasiswa c on b.nim = c.nim 
join tb_progdi a on c.id_progdi = a.id_progdi  
group by id_progdi

Solution

  • In your group by, you should add the table alias because you have the same column name in several tables and the db engine need to know at which you want to refer

        select a.id_progdi, a.nama_progdi, avg(b.ipk)  
        from tb_ipk b
        join  tb_mahasiswa c  on b.nim = c.nim 
        join tb_progdi a on c.id_progdi = a.id_progdi  
        group by a.id_progdi, a.nama_progdi