You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SQL 1:
SELECT
O.TARVAL ,
(CASE O.TARM_ID
when 'CP102' THEN '1' -- (only one space after CP102)
when 'CP11' THEN '2'
END) ID ,
count(*)
FROM test_1 O
WHERE
O.TARM_ID IN ('CP11','CP142','CP102','CP137')
group by
O.TARVAL ,
(CASE O.TARM_ID
when 'CP102' THEN '1' -- (only one space after CP102)
when 'CP11' THEN '2'
END);
it works .
SQL 2:
SELECT
O.TARVAL ,
(CASE O.TARM_ID
when 'CP102' THEN '1' --(the only diffence between sql1 and sql2 ,after 'CP102',more than one space)
when 'CP11' THEN '2'
END) ID ,
count(*)
FROM test_1 O
WHERE
O.TARM_ID IN ('CP11','CP142','CP102','CP137')
group by
O.TARVAL ,
(CASE O.TARM_ID
when 'CP102' THEN '1' -- (only one space after CP102)
when 'CP11' THEN '2'
END);
ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'example.O.TARM_ID' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by.
I think its a bug.and sql2 works on mysql server.
2. What did you expect to see? (Required)
sql 1 and sql2 all works on tidb server.
3. What did you see instead (Required)
an error 1055 .
4. What is your TiDB version? (Required)
all tidb version. and test in v6.3.
The text was updated successfully, but these errors were encountered:
old function dependency check is based on the text check between fields in the select list and group by field. you better keep them the same or just use the alias name ID in the group field like below.
SELECT O.TARVAL , (CASE O.TARM_ID when 'CP102' THEN '1' when 'CP11' THEN '2' END) ID , count(*) FROM test_1 O WHERE O.TARM_ID IN ('CP11','CP142','CP102','CP137') group by O.TARVAL , ID;
Empty set (0.01 sec)
Bug Report
1. Minimal reproduce step (Required)
1,create table test_1 (
TARM_ID VARCHAR(20) PRIMARY KEY ,
TARM_NM VARCHAR(240),
TARVAL VARCHAR(600),
TARAM_DATA_TPCD VARCHAR(19),
TARM_FMCTD VARCHAR(90) ,
STRTUS_DT DATE,
DSABL_DT DATE );
SQL 1:
SELECT
O.TARVAL ,
(CASE O.TARM_ID
when 'CP102' THEN '1' -- (only one space after CP102)
when 'CP11' THEN '2'
END) ID ,
count(*)
FROM test_1 O
WHERE
O.TARM_ID IN ('CP11','CP142','CP102','CP137')
group by
O.TARVAL ,
(CASE O.TARM_ID
when 'CP102' THEN '1' -- (only one space after CP102)
when 'CP11' THEN '2'
END);
it works .
SQL 2:
SELECT
O.TARVAL ,
(CASE O.TARM_ID
when 'CP102' THEN '1' --(the only diffence between sql1 and sql2 ,after 'CP102',more than one space)
when 'CP11' THEN '2'
END) ID ,
count(*)
FROM test_1 O
WHERE
O.TARM_ID IN ('CP11','CP142','CP102','CP137')
group by
O.TARVAL ,
(CASE O.TARM_ID
when 'CP102' THEN '1' -- (only one space after CP102)
when 'CP11' THEN '2'
END);
ERROR 1055 (42000): Expression #2 of SELECT list is not in GROUP BY clause and contains nonaggregated column 'example.O.TARM_ID' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by.
I think its a bug.and sql2 works on mysql server.
2. What did you expect to see? (Required)
sql 1 and sql2 all works on tidb server.
3. What did you see instead (Required)
an error 1055 .
4. What is your TiDB version? (Required)
all tidb version. and test in v6.3.
The text was updated successfully, but these errors were encountered: