当前位置:网站首页>MYSQL行转列例子
MYSQL行转列例子
2022-06-29 08:22:00 【蜗牛的小牛】
SELECT
person_id id,
max( CASE sex WHEN ‘男’ THEN ff.NAME END ) name1,
max( CASE sex WHEN ‘男’ THEN ff.sex END ) sex1,
max( CASE sex WHEN ‘女’ THEN ff.NAME END ) name2,
max( CASE sex WHEN ‘女’ THEN ff.sex END ) sex2
FROM
(
SELECT
bb.person_id,
bb.NAME,
bb.sex
FROM
B bb
JOIN (
SELECT
a.id id,
sum( 1 )
FROM
A a
JOIN B b ON a.id = b.person_id
GROUP BY
a.id
HAVING
sum( 1 ) >= 2
) tt ON bb.person_id = tt.id
) ff
GROUP BY
ff.person_id;
边栏推荐
- 2022年7月(软考高级)信息系统项目管理师认证招生简章
- Sorting out easily confused words in postgraduate entrance examination English 【 flash 】
- 对比HomeKit、米家,智汀家庭云版有哪些场景化的体验
- 开发小技巧-图片资源管理
- NP5 格式化输出(三)
- 华为设备配置小型网络WLAN基本业务
- The @dynamicmemberlookup and callasfunction features in swift implement the object transparent proxy function
- 机器人代码生成器之Robcogen使用教程
- 积分商城运营要如何做才能获取到利润
- [most complete] download and installation of various versions of PS and tutorial of small test ox knife (Photoshop CS3 ~ ~ Photoshop 2022)
猜你喜欢

Carbon emission reduction of second-hand trading platform, with assessment standards

闭关修炼(二十二)session和cookie原理

Huawei equipment is configured with medium-sized network WLAN basic services

Robcogen tutorial of robot code generator

MQTT第二话 -- emqx高可用集群实现

对比HomeKit、米家,智汀家庭云版有哪些场景化的体验

工厂模式
开发小技巧-图片资源管理

Actual combat memoir starts from webshell to break through the border

工厂模式和策略模式的区别
随机推荐
乘法器设计(流水线)verilog code
324. 摆动排序 II / 剑指 Offer II 102. 加减的目标值
Verilog 数据类型
51单片机中断与定时器计数器,基于普中科技HC6800-ESV2.0
观察者模式怎么实现
Transformer details
ThreadLocal thread variable
Feature selection: maximum information coefficient (MIC) [used to measure the degree of correlation between two variables X and y, linear or nonlinear strength, commonly used for feature selection of
闭关修炼(二十)如何做好单元测试
Matlab usage
First electric shock, so you are such a dragon lizard community | dragon lizard developer said that issue 8
TypeScript 變量聲明 —— 類型斷言
对比HomeKit、米家,智汀家庭云版有哪些场景化的体验
网上开股票账户真的安全吗?求答案
搭建开源物联网平台教程
TypeScript 变量声明 —— 类型断言
P4769-[NOI2018]冒泡排序【组合数学,树状数组】
Product manager certification enrollment brochure (NPDP) in July 2022
标准|中国支付清算协会发布首个隐私计算金融规范
Differences between x86 and x64