A Database Error Occurred Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column

user7474611

I have this query

SELECT substring(TGLLAHIR, 1, 7) as TGLLAHIR_,
       substring(TGLLAHIR, 5, 2) as BULAN, `TGLLAHIR` as `TGL`
FROM `m_pasien` 
WHERE substring(TGLLAHIR,1,4) = '2013' 
GROUP BY substring(TGLLAHIR, 1, 7) 
ORDER BY `TGLLAHIR` ASC

but message error showing

Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'rsukemba_kojarsuk.m_pasien.TGLLAHIR' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by

How do I solve this?

David דודו Markovitz

You don't need group by, use distinct instead

SELECT  distinct 
        substring(TGLLAHIR, 1, 7) as TGLLAHIR_
       ,substring(TGLLAHIR, 5, 2) as BULAN
       ,`TGLLAHIR` as `TGL` 
FROM `m_pasien` 
WHERE substring(TGLLAHIR,1,4) = '2013' 
ORDER BY `TGLLAHIR` ASC

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Mysql2::Error: Expression #5 of SELECT list is not in GROUP BY clause and contains nonaggregated column

Resolve Error SELECT list is not in GROUP BY clause and contains nonaggregated column

ERROR SqlExceptionHelper:146 - Expression #7 of SELECT list is not in GROUP BY clause and contains nonaggregated column

Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column. Getting error only in Shared Hosting cPanel

Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains nonaggregated column

#1055 - Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'osunemonitor.r.entry_date'

Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated column when try to create a View

MySql, SELECT list is not in GROUP BY clause and contains nonaggregated column

SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #3 of SELECT list is not in GROUP BY clause and contains nonaggregated

#1055 - Expression of SELECT list is not in GROUP BY clause and contains nonaggregated column this is incompatible with sql_mode=only_full_group_by

How to solve "SELECT list is not in GROUP BY clause and contains nonaggregated column" without adding the column into "group by"?

SELECT list is not in GROUP BY clause and contains nonaggregated column .... incompatible with sql_mode=only_full_group_by

SELECT list is not in GROUP BY clause and contains nonaggregated column; this is incompatible with sql_mode=only_full_group_by

Group by doesn't work (SELECT list is not in GROUP BY clause and contains nonaggregated column)

In aggregated query without GROUP BY, expression #1 of SELECT list contains nonaggregated column 'jquzntys.posts.id'

Select list contains nonaggregated column

After using any_value also getting error Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column

GROUP BY clause and contains nonaggregated column in Query

list contains nonaggregated column

MySQL - Doctrine: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression #1 of SELECT list is not in GROUP BY clause and contains

Laravel syntax error due to nonaggregated column with select DB:raw and GROUP BY

Select List is not in Group By Clause and Contains non-aggregated column

Mysql query error :SELECT list is not in GROUP BY clause and contains nonagregated column, incompatible with sql_mode=only_full_group_by

MYSQL INNER JOIN FUNCTION ERROR Expression #2 of SELECT list is not in GROUP BY clause

SELECT a column not in GROUP BY clause

Error Reading from Database ... invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause

ERROR 1055 (42000): Expression #1 of SELECT list is not in GROUP BY clause ... this is incompatible with sql_mode=only_full_group_by

Oracle Error message: not a GROUP BY expression when adding another 'Select' clause

How to fix column must appear in group by clause error in sql select