如何在 clickhouse 数据库中使用这种情况条件以 % 显示输出
P粉237125700
P粉237125700 2023-09-15 00:07:20
0
1
784

如何在 clickhouse 数据库中使用这种情况条件以 % 形式显示输出。

ROUND(count(distinct case when bt.status = 'approved' then bt.id else null end)/count(distinct p.id) * 100) as "SR- txns"

P粉237125700
P粉237125700

全部回复(1)
P粉754473468

但它按原样工作???

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 │
└──────────┘

Clickhouse 风格的语法:

select ROUND(uniqExactIf(id,status = 'approved')/uniqExact(id2) * 100) as "SR- txns"
from test
┌─SR- txns─┐
│       30 │
└──────────┘
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板