当前位置:网站首页>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
边栏推荐
- Talking about the advantages of flying book in development work | community essay solicitation
- Is GF futures safe? What do I need to open an account?
- Cusdis - 轻量级、隐私优先的开源评论系统 | 倾城之链
- 华为、阿里等大厂程序员真的好找对象吗?
- |How to analyze bugs? Professional summary and analysis
- qt打包exe文件,解决“无法定位程序输入点_ZdaPvj于动态链接库Qt5Cored.dll”
- LINQ 查询(3)
- 02 common codes for Epicor secondary development
- 软件测试人员的7个等级,据说只有1%的人能做到级别7
- How to get the picture outside the chain - Netease photo album [easy to understand]
猜你喜欢

做软件安全测试的作用,如何寻找软件安全测试公司出具报告?

进入阿里做测试员遥不可及?这里或许有你想要的答案

Use of hashcat

【STL源码剖析】STL六大组件功能与运用(目录)

When they are in private, they have a sense of propriety

EasyCVR国标协议接入的通道,在线通道部分播放异常是什么原因?

DataEase模板市场正式发布

Sumati GameFi生态纵览,神奇世界中的元素设计

Intégration de la plate - forme de test continu open source de metersphere avec Alibaba Cloud Effect devops

Hashcat 的使用
随机推荐
股票开账户如何优惠开户?手机开户是安全么?
进入阿里做测试员遥不可及?这里或许有你想要的答案
Notes on BGP part of CCNP
内网学习笔记(6)
Is it out of reach to enter Ali as a tester? Here may be the answer you want
Basic layout -qhboxlayout class, qvboxlayout class, qgridlayout class
Rod and Schwartz cooperated with ZhongGuanCun pan Lianyuan Institute to carry out 6G technology research and early verification
How can Huatai Securities open an account to achieve one in ten thousand? Are securities accounts safe and reliable
Resolution of cross reference in IDA
Qt中使用QDomDocument操作XML文件
write a number of lines to a new file in vim
Exploring the mystery of C language program -- C language program compilation and preprocessing
入坑机器学习:一,绪论
业务与技术双向结合构建银行数据安全管理体系
左手梦想 右手责任 广汽本田不光关注销量 还有儿童安全
【STL源码剖析】配置器(待补充)
会自动化—10K,能做自动化—20K,你搞懂自动化测试没有?
【FPGA】串口以命令控制温度采集
[mobile terminal] design size of mobile phone interface
The role of software security testing, how to find a software security testing company to issue a report?