I am working on oracle 11g and tried to execute this request
select code_mod,INTITULE,code_et,nom ,avg(note)
from note,exam,module,etudiant
where note.CODE_EX = exam.CODE_EX
and EXAM.CODE_MOD=MODULE.CODE_MOD
and NOTE.CODE_ET = ETUDIANT.CODE_ET
group by code_mod,code_et
order by code_mod;
but it says!
ORA-00918: column ambiguously defined
00918. 00000 - "column ambiguously defined"
*Cause:
*Action:
Error on line 6, colunn 19
what is wrong in it? if I execute this request, it works
select *
from note,exam,module,etudiant
where note.CODE_EX = exam.CODE_EX
and EXAM.CODE_MOD=MODULE.CODE_MOD
and NOTE.CODE_ET = ETUDIANT.CODE_ET;
you have at least two of code_mod
,INTITULE
,code_et
,nom
columns in note
,exam
,module
,etudiant
tables, and put them without aliases.
As an example both module
and exam
table include code_mod
column, and in the select list you didn't show where it comes from
Use like this :
select m.code_mod,intitule,et.code_et,nom ,avg(note)
from note n
inner join exam e on ( n.code_ex = e.code_ex )
inner join module m on ( e.code_mod=m.code_mod )
inner join etudiant et on ( et.code_et = n.code_et )
group by m.code_mod,intitule,et.code_et,nom
order by m.code_mod;
and you should include all columns in group by
expression without grouping functions
.