研发今天说group_concat函数导致结果显示不全。
group_concat作用:group_concat()函数,对查询的数据进行字符串连接操作。
默认group_concat的值为1024
临时调整:
set global group_concat_max_len=201400;
修改配置文件/etc/my.cnf
group_concat_max_len = 102400
具体SQL:
SELECT B.app_service AS Descr, COUNT(B.CountInInteval) AS TotalCount, GROUP_CONCAT(B.SysId) AS DetailLastSysIdStr, GROUP_CONCAT(B.CountInInteval) AS DetailCountStr FROM
(
SELECT A.SysId, A.app_service, COUNT(A.DiffTime) AS CountInInteval FROM
(
SELECT al2.SysId, al2.app_service, (UNIX_TIMESTAMP(al1.create_date) - UNIX_TIMESTAMP(al2.create_date)) AS DiffTime, al1.create_date AS create_date1, al2.create_date FROM
(
SELECT al.SysId, al.app_service, al.create_date
FROM access_log al
WHERE al.system_id = @SystemId AND al.app_service <> 'System/GetSystemMenuList'
AND al.create_date BETWEEN @StartDate AND @EndDate
) AS al1,
(
SELECT al.SysId, al.app_service, al.create_date
FROM access_log al
WHERE al.system_id = @SystemId AND al.app_service <> 'System/GetSystemMenuList'
AND al.create_date BETWEEN @StartDate AND @EndDate
) AS al2
WHERE al1.app_service = al2.app_service
) A
WHERE A.DiffTime >= @Inteval AND A.DiffTime <= 0
GROUP BY A.SysId, A.app_service
HAVING CountInInteval > 1
ORDER BY CountInInteval DESC
) B
GROUP BY B.app_service ORDER BY TotalCount DESC LIMIT 5;