There is a table:

  • disciplines: id, name;
  • marks: id, s_id, d_id, t_id, value;

It is necessary to create a related subquery for sampling the names of disciplines, the average score for which is higher than 3. In general, I haven’t been told anything, there is little information on the Internet, but I have found something. It turns out the internal query will compare each of the average values ​​of disciplines with a rating table with 3:

SELECT name FROM disciplines WHERE 3 < (SELECT AVG(value) FROM marks WHERE marks.d_id = disciplines.id GROUP BY marks.d_id); 

The request seems to be correct (the correct answer is displayed), but for some reason I doubt it. Please answer if it is correct.

  • so right or not? - Muscled Boy
  • Well, I would change places (SELECT AVG (value) FROM marks WHERE marks.d_id = disciplines.id GROUP BY marks.d_id) and <3, but somehow it is not human))) - Kryshtop
  • @Kryshtop, thank you, but do not see another one of my topics. If you do not consider it for arrogance) - Muscled Boy
  • @Kryshtop, look please. What is the problem: stackoverflow.com/questions/590592/… - Muscled Boy

0