sql - Sql如何在不丢失数据的情况下对列进行分组
解决方案
这很棘手。基本上,这个想法是一个不可旋转和重新旋转,但有一个转折:
select t.id,
max(case when which = 'codeTaxe1' then val end) as codeTaxe1,
max(case when which = 'codeTaxe2' then val end) as codeTaxe2,
. . .
from t cross apply
(select v.*, row_number() over (order by (select null)) as seqnum
from (values (t.codeTaxe1, 'codeTaxe1'), (t.codeTaxe2, 'codeTaxe2'), . . .
) v(val, which)
where val is not null
) tt
group by t.id, seqnum;
推荐阅读
- javascript - 比较两个对象并替换通用对象属性
- asp.net-core - InvalidCastException:无法将“System.Double”类型的对象转换为“System.Single”类型
- javascript - API Binance 获取免费余额
- postgresql - Postgres - 确定更新的列名
- sql - 在这种情况下,“日”表是个好主意吗?
- wordpress - 当我输入 wordpress https://example.com/wp-comments-post.php 时,我收到 http 405 错误。404重定向不发生
- python - python - 日期时间 x 绘图失真问题
- apache-kafka - 以分布式模式启动 Kafka 连接时出错
- javascript - 如何限制或改进执行 CPU 密集型终端命令的节点脚本
- reactjs - 反应钩子如何改变数组对象的属性