I have a query that shows me the earnings for each shop_id and country as below.
select shop_id,
country,
start_date,
sum(earnings) as earnings
from x
where country IN ('DE', 'IT', 'ES')
group by 1,2,3
However, I want to have only three shops in the country DE and all shops in the rest of the countries.
shop_id IN ('1', '2', '3')
How can I do this?
>Solution :
It sounds like your criteria could use some nesting, like this:
select shop_id,
country,
start_date,
sum(earnings) as earnings
from x
where country IN ('IT', 'ES')
OR (country = 'DE' AND sop_id IN ('1','2','3'))
group by 1,2,3