mysql查询的数据为同一天多行数据但是数据列不冲突,如何将数据展示的时候合并为一行 5

sql语句比较复杂,是需要查询的时候合并还是展示的时候合并SQL:SELECTdate(s.date)ASdateValue,type_value,over_imp,ro... sql语句比较复杂,是需要查询的时候合并还是展示的时候合并SQL:SELECT date( s.date ) AS dateValue, type_value, over_imp, round( over_imp * 1.0 / total_over_imp, 4 ) AS over_imp_ratio, advertiser_rtb_type AS '行业'FROM ( ( SELECT date, advertiser_rtb_type AS type_value, sum( over_impression ) AS over_imp FROM `account_entry_account_amount`, `users_userprofile` WHERE advertiser_id = `users_userprofile`.id AND date >= '2019-08-17 00:00:00' AND over_impression > 0 GROUP BY date, advertiser_rtb_type ) UNION ( SELECT date, CASE WHEN advertiser_rtb_type IN ( '丰胸减肥', '二类电商', '小病种类', '贷款', '游戏', '金融投资-优选', '网服-优选', '棋牌-优选', '招商加盟-优选', '职业培训-优选' ) THEN '拓展行业' ELSE '限定行业' END AS type_value, sum( over_impression ) AS over_imp FROM `account_entry_account_amount`, `users_userprofile` WHERE advertiser_id = `users_userprofile`.id AND date >= '2019-08-17 00:00:00' AND over_impression > 0 GROUP BY date, type_value ) ) AS s, ( SELECT date, sum( over_impression ) AS total_over_imp FROM `account_entry_account_amount` WHERE date >= '2019-08-17 00:00:00' GROUP BY date ) AS total_over_imp_info WHERE s.date = total_over_imp_info.date ORDER BY s.date,over_imp DESC 展开
 我来答
司马刀剑
高粉答主

2019-08-21 · 每个回答都超有意思的
知道顶级答主
回答量:4.6万
采纳率:93%
帮助的人:7573万
展开全部
您好.
以前有高人写过类似的:
select id,group_concat(re_id order by re_id separator ",") as re_id
from tablename
group by id
方法2:
select group_concat(list_name) from aa_list
如果还有问题,可以继续追问,感谢。
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式