当前位置:网站首页>psql 列转行
psql 列转行
2022-06-24 22:47:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
需求
学生成绩表
- 创建表初始化
CREATE TABLE public.test ( name VARCHAR(20), score FLOAT, total_availability FLOAT, shelf_availability FLOAT );
INSERT INTO public.test (name, score, total_availability, shelf_availability) VALUES ('A', 1, 1.1, 1.2);
INSERT INTO public.test (name, score, total_availability, shelf_availability) VALUES ('B', 3, 2.1, 2.2);
INSERT INTO public.test (name, score, total_availability, shelf_availability) VALUES ('C', 6, 3.3, 3.4);
INSERT INTO public.test (name, score, total_availability, shelf_availability) VALUES ('D', 10, 4.1, 4.2);
SELECT * FROM public.test;- 行转列
SELECT name, score, unnest(ARRAY ['total_availability' :: TEXT, 'shelf_availability' :: TEXT]) AS kpi_details, unnest( ARRAY [public.test.total_availability :: NUMERIC(30, 16), public.test.shelf_availability :: NUMERIC(30, 16)]) AS value FROM public.test;发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/151771.html原文链接:https://javaforall.cn
边栏推荐
- 多模态情感识别_多模态融合的情感识别研究「建议收藏」
- 指南针靠谱吗?开证券账户安全吗?
- Computing service network: a systematic revolution of multi integration
- Talking about the advantages of flying book in development work | community essay solicitation
- 探索C语言程序奥秘——C语言程序编译与预处理
- After integrating the aurora push plug-in in the uni app, the real machine debugging prompts "the currently running base does not contain the native plug-in [jg-jpush]..." Solutions to problems
- Left hand dreams right hand responsibilities GAC Honda not only pays attention to sales but also children's safety
- DDD concept is complex and difficult to understand. How to design code implementation model in practice?
- Intranet learning notes (7)
- tmux 如何自定义背景颜色 | How does the tmux color palette work?
猜你喜欢

1-6搭建Win7虚拟机环境

I've been doing software testing for two years. I'd like to give some advice to girls who are still hesitating

左手梦想 右手责任 广汽本田不光关注销量 还有儿童安全

EasyCVR平台EHOME协议接入,视频播放出现断流是什么原因?

Experience of epidemic prevention and control, home office and online teaching | community essay solicitation
Cusdis - lightweight, privacy first open source comment system | chain of the city

jwt

What are the reasons for the abnormal playback of the online channel of the channel accessed by easycvr national standard protocol?

Use of hashcat

Can automate - 10k, can automate - 20K, do you understand automated testing?
随机推荐
放养但没有完全放养(春季每日一题 2)
2个NPN三极管组成的恒流电路
TSDB在民机行业中的应用
The role of software security testing, how to find a software security testing company to issue a report?
I've been doing software testing for two years. I'd like to give some advice to girls who are still hesitating
Notes on BGP part of CCNP
业务与技术双向结合构建银行数据安全管理体系
同花顺是正规平台吗?同花顺开户安全吗
进入阿里做测试员遥不可及?这里或许有你想要的答案
记一次beego通过go get命令后找不到bee.exe的坑
Application of TSDB in civil aircraft industry
Four characteristics of actual attack and defense drill
Cake review fatigue in the secondary market of innovative drugs: phase III clinical success and product approval
Test / development programmers, 30, do you feel confused? And where to go
What are the reasons for the abnormal playback of the online channel of the channel accessed by easycvr national standard protocol?
当人们用互联网式的思维和视角来看待产业互联网的时候,其实已陷入到了死胡同
Fake wireless speakers in stores? Sony responded: the product has reserved a wired connection interface, which can be used in complex scenarios
入坑机器学习:一,绪论
Intranet learning notes (5)
What are the SQL aggregate functions