我有两个表应用程序和潜在客户
申请表
submitDate | fName | lName
2010-11-15 joe smith
2010-11-16 joe smith
2010-11-15 joe smith
线索表
submitDate | click | state
2010-11-15 1 ca
2010-11-16 1 ca
2010-11-16 1 ca
2010-11-15 1 ca
2010-11-15 1 ca
2010-11-15 1 ca
2010-11-15 1 ca
2010-11-15 1 ca
我想要一个查询来返回这个结果
submitDate | application | clicks | percent
2010-11-15 2 6 33%
2010-11-16 1 2 50%
我尝试了以下
SELECT `submitDate` , count(`submitDate`) AS 'comp',(select sum(`click`) from `leads`
WHERE `submitDate` between '2010-11-15' AND '2010-11-16' group by `submitDate`)as
'clicks' from `applications` WHERE `submitDate` between '2010-11-15' AND
'2010-11-16' group by `submitDate`
这返回一个错误
#1242 - Subquery returns more than 1 row
并尝试了以下
SELECT `leads`.`submitDate` , count(`leads`.`submitDate`)
AS 'application',sum(`click`) as 'clicks'
from `applications`,`leads` WHERE `leads`.`submitDate` between
'2010-11-15' AND '2010-11-16' group by `leads`.`submitDate`
这将返回以下结果
submitDate | application | clicks
2010-11-15 60 60
2010-11-16 6 6
潜在客户表有 22 列 / 20 = 2010-11-15 和 2 2010-11-16 应用表与上表相同
我很抱歉冗长的解释,但要清楚
任何想法?
以及添加划分应用程序/潜在客户的新字段百分比,因此结果将有 4 列
提前致谢