gpt4 book ai didi

Mysql 输出从双行到按键分组的单个原始数据

转载 作者:行者123 更新时间:2023-11-29 09:39:45 25 4
gpt4 key购买 nike

我有这个查询:

select key, propkey, propvalue 
from openidm.managedobjectproperties
where key in (
select key
from openidm.managedobjectproperties
where propvalue in ('97539510','97939103'))
and propkey in ('/CRSMID','/partyID');

它基本上返回这个输出:

key     | propkey  | propvalue
------------------------------
1482195 | /CRSMID | 814427
1482195 | /partyID | 97539510
1488492 | /CRSMID | 1415615
1488492 | /partyID | 97939103

对于每个键 - 相同 - 我想以这种方式输出一个带有属性值的两列表(第一列/CRSMID,第二列/partyID):

CRSMID  | partyID
-------------------
814427 | 97539510
1415615 | 97939103

但我不确定这一点,因为按键分组不起作用。

最佳答案

使用条件聚合

select max(case when propkey='/CRSMID' then  propvalue end) CRSMID,
max(case when propkey='/partyID' then propvalue end) partyID
from openidm.managedobjectproperties
where key in (
select key
from openidm.managedobjectproperties
where propvalue in ('97539510','97939103'))
and propkey in ('/CRSMID','/partyID') group by key

关于Mysql 输出从双行到按键分组的单个原始数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56867960/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com