I'm trying to show a default value, "Others", when the query does not return any result for one of the selected columns. I'll show you the example.
This query returns an empty value for os(agent) SO
(in the first row):
select country, os(agent) SO, count(*) from clicks_data
where country is not null and os(agent) is not null
group by country, os(agent);
Output:
ZA 4
ZA Android 4
ZA Mac 8
ZA Windows 5
Instead, I would like to get this result:
ZA Others 4
ZA Android 4
ZA Mac 8
ZA Windows 5
My next attempt was this query, but it's not really working, either:
select country, regexp_replace(os(agent),'','Others') SO, count(*) from clicks_data
where country is not null and os(agent) is not null
group by country, os(agent);
This is the result:
ZA Others 4
ZA OthersAOthersnOthersdOthersrOthersoOthersiOthersdOthers 4
ZA OthersMOthersaOtherscOthers 8
ZA OthersWOthersiOthersnOthersdOthersoOtherswOtherssOthers 5