简体   繁体   中英

Select one column and display values in two columns

I have the following Table Data

在此处输入图片说明

I want to split column a into two columns like this: Result Data

在此处输入图片说明

Person 00AB has given Paper1, Paper2, and Paper4.

What query will show in two columns which person has given the paper with 00AB.

You can try the following code:

select tableAB.a, tableP.a
from table as tableAB
inner join table as tableP on tableAB.b = tableP.b
where tableAB.a = '00AB'
and tableP.a != '00AB'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM