SQL 将多列转为一列,一行转为多行 (odps sql)

本文介绍如何使用ODPS SQL将数据表中的多列转换为一列,并实现一行数据拆分为多行,同时展示了如何获取转换后的前三个特征值。
摘要由CSDN通过智能技术生成

准备数据

create table if not exists tmp_table_friends
(
    name string comment '名字',
    appearance double comment '外貌',
    character double comment '性格',
    ability double comment '能力',
    humor double comment '幽默',
    job double comment '工作',
    figure double comment '外形',
    family double comment '家庭'
);

insert into tmp_table_friends
(name,appearance,character,ability,humor,job,figure,family) 
values
('Elizabeth',90,89,70,78,69,60,70),
('Bella',99,80,60,65,60,80,70),
('Melody',60,90,90,80,88,65,89),
('CC',92,80,66,69,70,89,80),
('Lili',90,80,80,60,70,80,60);

select * from tmp_table_friends ;

将多列转为一列,一行转为多行,并输出top3的特征;

select dist
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值