강의

멘토링

커뮤니티

Inflearn Community Q&A

uinnovation9832's profile image
uinnovation9832

asked

[Practice Makes Perfect] Intermediate SQL for Data Analysis

INNER JOIN HackerRank Problem Solving

SELECT 문에 왜 name이 안들어갈까요?

Written on

·

159

2

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

여기서 names of all the continents라고해서

SELECT country.name

     , FLOOR(AVG(city.population))

FROM city

    INNER JOIN country ON CITY.CountryCode = COUNTRY.Code

GROUP BY country.continent

이렇게 했었는데요.. GROUP BY의 이름과 같아야하기 때문에 바뀐건가요..?ㅠㅠ

SELECT 문에 왜 name이 안들어갈까요?

sql

Answer 1

0

bomin님의 프로필 이미지
bomin
Instructor

안녕하세요 u_innovation님

GROUP BY의 개념이 아직 정확하게 들어오지 않으신 것 같네요 :)

GROUP BY는 어떤 기준으로 연산을 해주어라라는 명령을 해주는 것이기 때문에 기준이 되는 컬럼은 반드시 SELECT문에 명시해주셔야 합니다.

이것은 GROUP BY라는 문법을 사용하는 기본적인 규칙이기 때문에 확실히 숙지하고 넘어가시는 게 좋을 것 같아 관련 강의 내용 첨부드립니다.

GROUP BY 이론

감사합니다.

uinnovation9832's profile image
uinnovation9832

asked

Ask a question