我有两个 mySQL 查询可以正常工作。第一个获取推荐人,第二个计算国家/地区的百分比和数字。但是,我需要在第一个查询中包含国家/地区百分比和数字,换句话说,我怎样才能将它们一起使用?
SELECT *, COUNT(*) FROM track
where referid='".$member."'
GROUP BY referer
ORDER BY id desc limit 0,15
select id, country, num, num*100/total pct
from (SELECT id,country, count(*) as num
FROM track GROUP BY country
ORDER BY num desc limit 3) x
join (select count(*) total from track) y