mysql数据库:
SELECT
IF ( AVG (cai.conversionsRate) IS NULL , 0 , AVG (cai.conversionsRate))
AS conversionsRate
FROM campaign_info cai
WHERE insertTime BETWEEN ' 2011-02-01 ' AND ' 2011-02-04 ' AND googleCampaignId = 23331401
IF ( AVG (cai.conversionsRate) IS NULL , 0 , AVG (cai.conversionsRate))
AS conversionsRate
FROM campaign_info cai
WHERE insertTime BETWEEN ' 2011-02-01 ' AND ' 2011-02-04 ' AND googleCampaignId = 23331401
Ms-SqlServer数据库
/*
MS-SqlServer去除NULL值
*/
select ISNULL ( avg (cai.conversionsRate), 0 )
AS conversionsRate
FROM campaign_info cai
WHERE insertTime BETWEEN ' 2010-02-11 ' AND ' 2011-01-23 ' AND googleCampaignId = 42722951
select ISNULL ( avg (cai.conversionsRate), 0 )
AS conversionsRate
FROM campaign_info cai
WHERE insertTime BETWEEN ' 2010-02-11 ' AND ' 2011-01-23 ' AND googleCampaignId = 42722951