首页 > 解决方案 > 过滤掉具有空值的行

问题描述

如何过滤掉具有空值的行?

SELECT country_table.country as country, 
(SELECT TRUNCATE(AVG(news_guard_score), 3) FROM news WHERE news.country_id = country_table.country_id) as 'avg_news_score'
FROM country_table
-- WHERE country_table.country_id IS NOT NULL
GROUP BY country;

它不适用于注释代码

它看起来如何

我需要它没有最后一行

标签: mysql

解决方案


你有没有尝试过:

SELECT country_table.country as country, 
(SELECT TRUNCATE(AVG(news_guard_score), 3) FROM news WHERE (news.country_id = country_table.country_id AND country_table.country_id IS NOT NULL)) as 'avg_news_score'
FROM country_table
GROUP BY country;

推荐阅读