EID COLA COLB
1 name A
1 age 23
1 city hyd
1 email [email protected]
1 mobile 45126
2 name B
2 age 43
2 city bang
3 name C
3 age 13
3 city bang
3 email [email protected]
我想有输出如下
ID||COLA||COLB
1||name||A
1||age||23
1||city||hyd
1||email||[email protected]
1||mobile||45126
2||name||B
2||age||43
2||city||bang
2||email||NULL
2||mobile||NULL
3||name||C
3||age||13
3||city||bang
3||email||[email protected]
3||mobile||NULL
你能请让我知道如何做到这一点输出。 如何显示任何必填字段(名称,年龄,城市,电子邮件,移动)缺失的结果,那么它应显示为该字段为空,在我们通过过滤单个id在where子句中提供的查询中价值和可乐为(姓名,年龄,城市,电子邮件,手机)
我查询:
select
case colA
when cola then colA+'||'+colB
end
from tbl
where cola in ('name','age','city','email','mobile')