2016-01-21 9 views
10

निम्न त्रुटि प्राप्त:चयन सूची ग्रुप में BY खंड नहीं है और nonaggregated कॉलम होता है

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 चल रहा है।

कोई विचार ??? : ओ

+1

आप 'ONLY_FULL_GROUP_BY' विकल्प होता है सक्षम, जो 'GROUP BY' के बारे में MySQL के आराम से नियमों को हटा देता है। – Barmar

+0

उस विकल्प के लिए डिफ़ॉल्ट MySQL 5.7 में बदल गया। – Barmar

उत्तर

1

country.code आपके group by कथन में नहीं है, और कुल योग नहीं है (कुल कार्य में लपेटा गया है)।

http://www.w3schools.com/sql/sql_functions.asp

+0

लिंक अब और काम नहीं कर रहा है, उत्तर देने के दौरान हाइपरलिंक्स के स्थान पर वास्तविक सामग्री पोस्ट करने का प्रयास करें। – amey

11

@Brian रिले के रूप में पहले से ही आप या तो अपने चयन

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 ; 

में 1 कॉलम को दूर करने या अपने समूह में जोड़ने चाहिए कहा

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 ; 
+0

इसके लिए धन्यवाद। इससे बहुत मदद मिली! – racl101

+0

या बस mysql कमांड लाइन से चलाएं: सेट ग्लोबल sql_mode = (चयन करें (@@ sql_mode, 'ONLY_FULL_GROUP_BY', '')); –

संबंधित मुद्दे