复杂的SQL语句,查询一张表的结果生成另外一张表的字段

img


select bsrq as '比赛日期', SUM(sl) as '胜', SUM(sb) as '负' from (
  select match_date as bsrq, count(Result) as sl, 0 as sb from match_record  where Result = '胜' group by match_date 
  union all
  select match_date as bsrq, 0 as sl, count(Result) as sb from match_record  where Result = '负' group by match_date 
) t group by bsrq 

剩下的可以再优化