Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql Group_concat()剪切一些行_Mysql_Group Concat - Fatal编程技术网

Mysql Group_concat()剪切一些行

Mysql Group_concat()剪切一些行,mysql,group-concat,Mysql,Group Concat,我的质询如下: select id, value from X where sig_id=1; -->获取近1000行 但是当我使用 select id, round(SUBSTRING_INDEX(group_concat(if(sig_id =1, value,0) order by sig_value desc),',',1),2) from X; -->仅获取1行 I also get a warning, Row 74 was cut by GROUP_CONCAT()

我的质询如下:

select id, value from X where sig_id=1; 
-->获取近1000行

但是当我使用

select id,
round(SUBSTRING_INDEX(group_concat(if(sig_id =1, value,0) order by sig_value desc),',',1),2) 
from X; 
-->仅获取1行

I also get a warning,

Row 74 was cut by GROUP_CONCAT()

如何解决这一问题?

正如我所看到的,在下面的查询中,您正在执行一个
分组\u CONCAT()
,而没有任何
分组依据
,因此分组是作为单个组对整个结果集进行的。因此,只产生一条记录

select id,
round(SUBSTRING_INDEX(group_concat(if(sig_id =1, value,0) order by sig_value desc),',',1),2) 
from X;

实际上,您可能希望在某些列上使用
groupby
,比如
id
列,以获得多个分组结果。

是,谢谢。我的错。。我错过了。不知什么原因,直到现在我才接受我的答案。。朱斯现在能够做到这一点。做到了:)容易。不要使用分组讨论。按照我的想法,SQL中(几乎)没有任何问题,哪一个组是解决方案