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
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |