clickhouse行转列的转换

1、原表select * from test

2、一个人的每个科目作为一行记录 改为一个人的所有科目作为一行记录

方式1

select name,

sum(case when subject='语文' then score else 0 end) as chinese,

sum(case when subject='数学' then score else 0 end) as math

from test

group by name

方式二示例

multiIf、if写法

3、列转行

相关推荐
fire-flyer1 天前
ClickHouse系列(九):慢查询、内存 OOM 与稳定性治理
android·clickhouse
fire-flyer1 天前
ClickHouse系列(十):生产架构与最佳实践总结
clickhouse·架构
fire-flyer2 天前
ClickHouse系列(八):ClickHouse 的 UPDATE / DELETE 正确姿势
大数据·数据库·clickhouse
fire-flyer2 天前
ClickHouse系列(七):Materialized View 与多分辨率 Rollup 设计
大数据·数据库·clickhouse·架构
fire-flyer3 天前
ClickHouse系列(二):MergeTree 家族详解
大数据·数据库·clickhouse
fire-flyer3 天前
ClickHouse系列(四):压缩不是为了省磁盘,而是为了更快的查询
数据库·clickhouse
l1t3 天前
测试clickhouse 26.3的新功能
数据库·clickhouse
fire-flyer3 天前
ClickHouse系列(五):ClickHouse 写入链路全解析(Insert 到 Merge)
大数据·clickhouse·架构
fire-flyer3 天前
ClickHouse系列(六):Kafka 到 ClickHouse 的生产级写入架构
clickhouse·架构·kafka
fire-flyer4 天前
ClickHouse系列 (一):为什么 ClickHouse 具备高性能分析能力
大数据·数据库·clickhouse