MariaDB [mart]> SELECT last_name, year(date_of_birth) FROM efis_people LIMIT 5; +-----------+---------------------+ | last_name | year(date_of_birth) | +-----------+---------------------+ | Aadamsoo | 1975 | | Aaloe | 1944 | | Aamisepp | NULL | | Aanja | NULL | | Aanja | NULL | +-----------+---------------------+ MariaDB [mart]> SELECT DISTINCT classificator_code FROM efis_film_role_person; +--------------------+ | classificator_code | +--------------------+ | FILM_ROLE_MAIN | | FILM_ROLE_SIDE | | FILM_ROLE_EPISODE | +--------------------+ SELECT YEAR(date_of_birth) FROM efis_people JOIN efis_film_role_person ON efis_film_role_person.people_id=efis_people.id WHERE classificator_code='FILM_ROLE_MAIN' AND NOT YEAR(date_of_birth) IS NULL; SELECT YEAR(date_of_birth) FROM efis_people JOIN efis_film_role_person ON efis_film_role_person.people_id=efis_people.id WHERE classificator_code='FILM_ROLE_SIDE' AND NOT YEAR(date_of_birth) IS NULL; SELECT AVG(YEAR(date_of_birth)) FROM efis_people JOIN efis_film_role_person ON efis_film_role_person.people_id=efis_people.id WHERE classificator_code='FILM_ROLE_SIDE' AND NOT YEAR(date_of_birth) IS NULL; library(RMySQL) yhendus<-dbConnect(dbDriver("MySQL"), user='mart', password='ajutine1234', host='localhost', dbname='mart' ) paring<-dbSendQuery(yhendus, " SELECT YEAR(date_of_birth) AS synniaasta FROM efis_people JOIN efis_film_role_person ON efis_film_role_person.people_id=efis_people.id WHERE classificator_code='FILM_ROLE_MAIN' AND NOT YEAR(date_of_birth) IS NULL") andmed=fetch(paring, n=-1) #print(andmed$synniaasta) paring<-dbSendQuery(yhendus, " SELECT YEAR(date_of_birth) AS synniaasta FROM efis_people JOIN efis_film_role_person ON efis_film_role_person.people_id=efis_people.id WHERE classificator_code='FILM_ROLE_SIDE' AND NOT YEAR(date_of_birth) IS NULL") andmed2=fetch(paring, n=-1) #print(andmed2$synniaasta) t.test(andmed$synniaasta, andmed2$synniaasta) data: andmed$synniaasta and andmed2$synniaasta t = 2.2874, df = 8786, p-value = 0.0222 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: 0.1537264 1.9960063 sample estimates: mean of x mean of y 1950.466 1949.391