I receive an error that the column ls.amount is in field list when I run the following query.
Can anyone help me diagnose the problem.
SELECT c.name, ic.keyword, 开发者_如何学编程COUNT(ic.keyword), SUM(ls.amount), ls.buyer FROM in_clicks AS ic
INNER JOIN ads AS a ON ic.ad_id = a.id
INNER JOIN ad_groups AS ag ON a.ad_group_id = ag.id
INNER JOIN campaigns AS c ON ag.campaign_id = c.id;
INNER JOIN leads AS l ON (ic.id = l.in_click_id)
INNER JOIN lead_status AS ls ON (l.id = ls.lead_id)
WHERE ic.create_date LIKE '%2011-08-19%' AND ic.location NOT LIKE '%Littleton%' AND discriminator LIKE '%AUTO_POST%'
GROUP BY ic.keyword ORDER BY COUNT(ic.keyword) DESC
The exact error message is:
Error Code: 1054
Unknown column 'ls.amount' in 'field list'
Drop the semicolon (;
) on line 4. I suspect that is ending you query before you can define the ls
alias.
SELECT c.name,
ic.keyword,
COUNT(ic.keyword),
SUM(ls.amount),
ls.buyer
FROM in_clicks AS ic
INNER JOIN ads AS a
ON ic.ad_id = a.id
INNER JOIN ad_groups AS ag
ON a.ad_group_id = ag.id
INNER JOIN campaigns AS c
ON ag.campaign_id = c.id
INNER JOIN leads AS l
ON ( ic.id = l.in_click_id )
INNER JOIN lead_status AS ls
ON ( l.id = ls.lead_id )
WHERE ic.create_date LIKE '%2011-08-19%'
AND ic.location NOT LIKE '%Littleton%'
AND discriminator LIKE '%AUTO_POST%'
GROUP BY ic.keyword
ORDER BY COUNT(ic.keyword) DESC
精彩评论