B
B
bufon1122018-05-29 14:07:40
MySQL
bufon112, 2018-05-29 14:07:40

What did you write wrong in sql query?

There are 2 tables:
result:
competition_id (competition ID);
sportsman_id (athlete ID);
result (athlete result);
city ​​(venue);
hold_date (hold date);
sportsman
sportsman_id (sportsman ID);
sportsman_name (athlete name);
rank (athlete's rank);
year_of_birth (year of birth);
personal_record (personal record);
country (country of the athlete);
Required - Output the years of birth of athletes whose result in Milan is above the average for all athletes.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2018-05-29
@alexey-m-ukolov

WHERE city = 'Milan' > AVG(result)
What are you trying to write here? This expression is invalid, hence the error. The syntax of the condition in JOIN is also incorrect, some columns must be compared there, and you wrote the table name again.

J
Justique, 2018-05-29
@Justique

I can't check but I think it should be something like this

SELECT sportsman.year_of_birth, AVG(result.result)
FROM sportsman 
INNER JOIN result 
ON result.sportsman_id = sportsman.sportsman_id
WHERE result.city = 'Милан'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question