반응형
SELECT 목록이 GROUP BY 절에 없으며 집계되지 않은 열을 포함합니다.
다음 오류 수신:
Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'world.country.Code' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by
다음 쿼리를 실행할 때:
select countrylanguage.language, country.code, sum(country.population*countrylanguage.percentage/100)
from countrylanguage
join country on countrylanguage.countrycode = country.code
group by countrylanguage.language
order by sum(country.population*countrylanguage.percentage) desc ;
MySQL 월드 테스트 데이터베이스(http://dev.mysql.com/doc/index-other.html) 를 사용합니다.왜 이런 일이 벌어지는지 모르겠어요.현재 MYSQL 5.7.10을 실행 중입니다.
무슨 생각 있어요?? :O
@Brian Riley가 이미 말했듯이 선택한 항목에서 1개의 열을 제거해야 합니다.
select countrylanguage.language ,sum(country.population*countrylanguage.percentage/100)
from countrylanguage
join country on countrylanguage.countrycode = country.code
group by countrylanguage.language
order by sum(country.population*countrylanguage.percentage) desc ;
그룹에 추가할 수 있습니다.
select countrylanguage.language, country.code, sum(country.population*countrylanguage.percentage/100)
from countrylanguage
join country on countrylanguage.countrycode = country.code
group by countrylanguage.language, country.code
order by sum(country.population*countrylanguage.percentage) desc ;
country.code당신 안에 없습니다.group byaggregate 함수에 포함된 aggregate가 아닙니다.
https://www.w3schools.com/sql/sql_ref_sqlserver.asp
언급URL : https://stackoverflow.com/questions/34913281/select-list-is-not-in-group-by-clause-and-contains-nonaggregated-column
반응형
'programing' 카테고리의 다른 글
| jquery 데이터 테이블 열 숨기기 (0) | 2023.09.17 |
|---|---|
| j과거 날짜를 방지하기 위한 날짜 선택기 쿼리 (0) | 2023.09.17 |
| Swift 3.0으로 컴파일된 모듈은 Swift 3.0.1에서 가져올 수 없습니다. (0) | 2023.09.17 |
| NextGen 갤러리에 라이트박스 효과 추가 워드프레스 (0) | 2023.09.12 |
| 여러 열 중복의 발생을 기준으로 표시 및 그룹화하는 SQL (0) | 2023.09.12 |