两张表整合、去重统计和


SELECT SUM(aa), qq.bb FROM (
SELECT COUNT(dai_number) AS aa,b.`real_name` AS bb
FROM tb_issue AS a ,tb_user AS b WHERE create_user=b.`user_id` AND dai_number>1000 GROUP BY b.`real_name`
UNION
SELECT SUM(dai_number) AS aa,b.`real_name` AS bb
FROM tb_issue AS a ,tb_user AS b WHERE create_user=b.`user_id` AND dai_number<1000 GROUP BY b.`real_name`
) AS qq  GROUP BY bb

你可能感兴趣的:(两张表整合、去重统计和)