我有一个表,其中列有:国家、年份、值、 我需要找到2015至2018年间和2019至2022年间其值之和大于1的国家. 我试着用亚库里不欠我的
select countries
FROM diamonds_export_long
WHERE year between '2015' and '2018'
GROUP BY countries , year
having sum(value_millions) = 0
这给出了部分结果,然后我try 使用子查询不起作用
SELECT countries
FROM diamonds_export_long
GROUP BY countries ,year
having (year between '2015' and '2018' and sum(value_millions) = 0)
and (year between '2019' and '2021'and sum(value_millions) > 1)
这看起来更正确,但没有效果 或许使用CASE的解决方案