looking for some solutions? You are welcome.

SOLVED: Getting wrong answer for below query

djabhi121:

Given the CITY and COUNTRY tables, query the names of all the continents (COUNTRY.Continent) and their respective average city populations (CITY.Population) rounded down to the nearest integer.

Note: CITY.CountryCode and COUNTRY.Code are matching key columns.

COUNTRY SCHEMA

CITY SCHEMA

Accepted one

select COUNTRY.CONTINENT, FLOOR(AVG(CITY.POPULATION)) 
FROM COUNTRY , CITY WHERE COUNTRY.CODE = CITY.COUNTRYCODE GROUP BY COUNTRY.CONTINENT;

As we know that in country table population of each country given and we can use the country table itself here so why i am getting wrong answer for this ?

SELECT C1.CONTINENT , FLOOR(AVG(C1.POPULATION))
FROM COUNTRY C1,COUNTRY C2    WHERE C1.CODE=C2.CODE GROUP BY C1.CONTINENT;



Posted in S.E.F
via StackOverflow & StackExchange Atomic Web Robots
Share:

No comments:

Recent