create table test(id int, id2 int, status String) Engine=Memory
as select number,number, ['approved', 'completed'][number%3] from numbers(10);
select ROUND(count(distinct case when status = 'approved' then id else null end)/count(distinct id2) * 100) as "SR- txns"
from test
┌─SR- txns─┐
│ 30 │
└──────────┘
Sintaks gaya clickhouse:
select ROUND(uniqExactIf(id,status = 'approved')/uniqExact(id2) * 100) as "SR- txns"
from test
┌─SR- txns─┐
│ 30 │
└──────────┘
Tetapi ia berfungsi seperti sedia ada? ? ?
Sintaks gaya clickhouse: