Answer the question
In order to leave comments, you need to log in
How to do arithmetic mean in SQL query?
How to create an arithmetic mean of `stud`.`E1`, `stud`.`E2`, `stud`.`E3` both in rows, as it is now, and in columns to get one number?
SELECT `stud`.`Name`
FROM `stud`
WHERE EXISTS(SELECT NumS
FROM `rob_gurt`
WHERE
((`stud`.`NumS` = `rob_gurt`.`NumS`) AND (`rob_gurt`.`NumG` = 1) AND ( `stud`.`E1`<=
(`stud`.`E1` + `stud`.`E2` + `stud`.`E3`)/3) )
)
Answer the question
In order to leave comments, you need to log in
SELECT `stud`.`Name`
FROM `stud`
INNER JOIN
(SELECT AVG(`stud`.`E1` + `stud`.`E2` + `stud`.`E3`) / 3 AS average
FROM `stud`
INNER JOIN `rob_gurt`
ON `rob_gurt`.`NumS` = `stud`.`NumS`
INNER JOIN `gurt`
ON `gurt`.`NumG` = `rob_gurt`.`NumG`
WHERE `gurt`.`NameG` = "Music") AS q
ON `stud`.`E1` <= q.average
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question