0
數據庫表:優化MySQL查詢(生成統計)
我有MySQL查詢:
select calendar.datefield AS date,
(SELECT IFNULL(SUM(visits),0)
FROM link_stats
WHERE link_stats.link_id = '1'
AND statDate = date
) AS visits,
(SELECT Round(IFNULL(SUM(leads * (rate/1000)),0),3)
FROM link_stats
WHERE link_stats.link_id = '1'
AND statDate = date
) AS cash,
(SELECT IFNULL(SUM(leads),0)
FROM link_stats
WHERE link_stats.link_id = '1'
AND statDate = date
) AS leads
from `calendar`
where `calendar`.`datefield` between '2016-05-10' AND '2016-05-11'
我嘗試生成空白天數鏈接統計報告。
例子:
之間2016年11月1日至20-01-2016和鏈接不具有日期2016年12月1日的記錄。