请帮忙...
我正在尝试使用 SQL 从我的网站 www.mentallica.co.il 获取流量数据问题是当我使用两个或更多时,我的左连接查询返回不同的值。
SELECT ISNULL(SUM([TrafficDay].UniqueTraffic), 0) AS TrafficDay,
[Topics].topicNumber
FROM [Topics]
LEFT JOIN [Traffic] AS TrafficDay
ON ([TrafficDay].Date >= '10/16/2013'
AND [TrafficDay].Date <= '10/16/2013')
AND [TrafficDay].TopicNumber = [Topics].TopicNumber
GROUP BY [Topics].TopicNumber
将返回一个TrafficDay
实际值
问题查询是
SELECT ISNULL(SUM([TrafficDay].UniqueTraffic), 0) AS TrafficDay,
ISNULL(SUM([TrafficWeek].UniqueTraffic), 0) AS TrafficWeek,
[Topics].topicNumber
FROM [Topics]
LEFT JOIN [Traffic] AS TrafficDay
ON ([TrafficDay].Date >= '10/16/2013'
AND [TrafficDay].Date <= '10/16/2013')
AND [TrafficDay].TopicNumber = [Topics].TopicNumber
LEFT JOIN [Traffic] AS TrafficWeek
ON ([TrafficWeek].Date > '10/09/2013'
AND [TrafficWeek].Date < '10/16/2013')
AND [TrafficWeek].TopicNumber = [Topics].TopicNumber
GROUP BY [Topics].TopicNumber
这将返回不同(更大)的值TrafficDay
这是为什么 ?如何获得TrafficDay
and的实际值TrafficWeek
?
任何解决方案都会很棒!如何根据其他表值加入同一个表...