当前位置:网站首页>MySQL row column conversion example
MySQL row column conversion example
2022-06-29 08:59:00 【Snail's calf】
SELECT
person_id id,
max( CASE sex WHEN ‘ male ’ THEN ff.NAME END ) name1,
max( CASE sex WHEN ‘ male ’ THEN ff.sex END ) sex1,
max( CASE sex WHEN ‘ Woman ’ THEN ff.NAME END ) name2,
max( CASE sex WHEN ‘ Woman ’ 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;
边栏推荐
- ES6数据类型Map&Set
- Is it safe for the top ten securities companies to open accounts? Is it reliable?
- 递归方法 rbac菜单层级显示 无限极分类
- Calculus Learning
- 51单片机中断与定时器计数器,基于普中科技HC6800-ESV2.0
- uniapp引入组件不生效解决方法
- Tutorial on building open source Internet of things platform
- 十大券商账号开户安全吗?是靠谱的吗?
- Figure timers in SOC (I): what timers are there in the system?
- hostname -f与uname -n的返回值可能不同
猜你喜欢

Calculus Learning

2022春夏系列 KOREANO ESSENTIAL重塑时装生命力

How to recover data loss of USB flash disk memory card

How to recite words in tables

2022第六季完美童模 合肥赛区 决赛圆满落幕

51单片机中断与定时器计数器,基于普中科技HC6800-ESV2.0

Some "non-technical" Thoughts on distributed digital identity

TypeScript 变量声明 —— 类型断言

Mqtt second session -- emqx high availability cluster implementation

标准|中国支付清算协会发布首个隐私计算金融规范
随机推荐
Did you really make things clear when you were promoted or reported?
Self attention mechanism
Working for many years, recalling life -- three years in high school
Baodawei of the people's Chain: break down barriers and establish a global data governance sharing and application platform
2022第六季完美童模 清远赛区 海选赛圆满落幕
C# 语音端点检测(VAD)实现过程分析
The difference and usage of JS for in loop and for of loop
(III) encoder self attention mask
How to recite words in tables
P6776-[NOI2020]超现实树
P4769-[noi2018] bubble sort [combinatorics, tree array]
(pytorch进阶之路三)encoder self attention mask
启牛学堂让开的证券账户是真的安全靠谱吗?
Measure the level of various chess playing activities through ELO mechanism
华为设备配置中型网络WLAN基本业务
Backpack Lecture 9 - detailed understanding and code implementation
抽象类、接口
Product manager certification enrollment brochure (NPDP) in July 2022
单例模式的理解
Write time replication of hugetlbfs