Hi guys I am making database in MSSMS and I have question how can I SELECT AVG AGE from two tablets?
Table 1 :
CREATE TABLE Zamestnanci
(id_Zamestnanca int not null,
Meno varchar(50) null,
Priezvisko varchar(50)null,
Adresa varchar(50) null,
Datum_narodenia date null,
PRIMARY KEY (id_Zamestnanca)
);
Table 2 :
CREATE TABLE ObčaniaSR
(id_Občana int not null,
Meno varchar(50) null,
Priezvisko varchar(50) null,
Adresa varchar(50) null,
Datum_narodenia date null,
Zápis_v_trestnom_registry varchar(50) null,
PRIMARY KEY (id_Občana)
);
The value Datum_narodenia means Age .
I've tried this :
*SELECT AVG(Datum_narodenia), Datum_narodenia
FROM Zamestnanci INNER
JOIN ObčaniaSR
ON Datum_narodenia = Datum_narodenia
GROUP BY priemerny vek; *
But it got me errors Msg 209, Level 16, State 1, Line 6
Ambiguous column name 'Datum_narodenia'.
Msg 209, Level 16, State 1, Line 6
Ambiguous column name 'Datum_narodenia'.
Msg 209, Level 16, State 1, Line 7
Ambiguous column name 'Datum_narodenia'.
Msg 209, Level 16, State 1, Line 3
Ambiguous column name 'Datum_narodenia'.
Msg 209, Level 16, State 1, Line 3
Ambiguous column name 'Datum_narodenia'.
Thank you for your answers and advices