SQL Select random rows partitioned by a column
This should work:
select Country, id from
(select Country,
id,
row_number() over(partition by Country order by rand()) as rn
from table_name
) t
where Country in ('a', 'c') and rn <= 2
Replace rand()
with random()
if you're using Postgres or newid()
in SQL Server.