当前位置:网站首页>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
边栏推荐
- linux上查看mysql的密码_Linux下MySQL忘记密码「建议收藏」
- TSDB在民机行业中的应用
- 都2022年了,你还不了解什么是性能测试?
- Sumati GameFi生态纵览,神奇世界中的元素设计
- Beescms website penetration test and repair comments "suggestions collection"
- 软件测试人员的7个等级,据说只有1%的人能做到级别7
- Explanation of FTP protocol
- Integration of metersphere open source continuous testing platform and Alibaba cloud cloud cloud efficient Devops
- File system - basic knowledge of disk and detailed introduction to FAT32 file system
- Is it out of reach to enter Ali as a tester? Here may be the answer you want
猜你喜欢

Application of TSDB in civil aircraft industry

Redis 那些事

Use of hashcat

常用的软件测试工具清单,请查收。
Cusdis - lightweight, privacy first open source comment system | chain of the city

Left hand dreams right hand responsibilities GAC Honda not only pays attention to sales but also children's safety

qt打包exe文件,解决“无法定位程序输入点_ZdaPvj于动态链接库Qt5Cored.dll”

Rod and Schwartz cooperated with ZhongGuanCun pan Lianyuan Institute to carry out 6G technology research and early verification

Intranet learning notes (7)

How to quickly familiarize yourself with the code when you join a new company?
随机推荐
业务与技术双向结合构建银行数据安全管理体系
How to quickly familiarize yourself with the code when you join a new company?
Please run IDA with elevated permissons for local debugging.
Beescms website penetration test and repair comments "suggestions collection"
Taishan Office Technology Lecture: a simple study of Chinese punctuation in vertical arrangement
write a number of lines to a new file in vim
ida中交叉引用的解析
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
Computing service network: a systematic revolution of multi integration
How can Huatai Securities open an account to achieve one in ten thousand? Are securities accounts safe and reliable
Kaggle 专利匹配比赛赛后总结
The role of software security testing, how to find a software security testing company to issue a report?
Fake wireless speakers in stores? Sony responded: the product has reserved a wired connection interface, which can be used in complex scenarios
Talking about the advantages of flying book in development work | community essay solicitation
算力服务网络:一场多元融合的系统革命
股票开账户如何优惠开户?手机开户是安全么?
Use of hashcat
TSDB在民机行业中的应用
Which account is safer and better for access letter
【FPGA】串口以命令控制温度采集