当前位置 : 主页 > 数据库 > mysql >

mysql中将null值转换为0的语句

来源:互联网 收集:自由互联 发布时间:2021-07-07
复制代码 代码如下: 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

复制代码 代码如下:
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

网友评论