Why does it say column ambiguously defined?

78 views Asked by At
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
3

There are 3 answers

0
ScaisEdge On BEST ANSWER

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
1
Francesco On

you have multiple id_progdi so probably it doesn't know which one to refer to in the group by. Change it to group by a.id_progdi

0
Nikhil S On

maybe you have id_progdi in multiple tables use table alias for it in your group by.