How do I efficiently compute a distinct count for ...
# general
t
How do I efficiently compute a distinct count for column a that is depend on the value of column b, like this:
Copy code
select FLOOR(10000*count(distinct case when action = 'pay' then user_id else '' end) / count(distinct case when action = 'browse' then user_id else '' end))/100 from "capi_trace" where company_id = 'aaaaa' and __time >= '1622554026000' and __time <= '1625146026000' and shop_id in ('xxxxx')
Is it possible without using case when inside distinct count?
k
Group by action?
t
If group by action, how should I write the divide section in select clause?
k
You will have to perform that on the client side
Or do something similar to theta sketch implementation.
t
I see, thanks.