我在Oracle中有以下sql查询。
SELECT pr.uuid AS masterproductid,
(case
when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint1"]/string/text()') IS NOt NULL THEN 'sellingpoint1'
when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint2"]/string/text()') IS NOt NULL THEN 'sellingpoint2'
END
) as testt
FROM product pr WHERE pr.defaultproductvariationid =(SELECT prv.uuid FROM productvariation prv WHERE prv.uuid = '3rep_vEBP6IAAAE83REjnPbb' AND pr.typecode='16')
在这种情况下 - 当'sellingpoint1'和'sellpoint2'都不为null但这个查询只返回sellpoint1时,我想要'sellpoint2',我怎么能得到它?
感谢您的帮助
答案 0 :(得分:0)
这将它分为两列:
SELECT pr.uuid AS masterproductid,
(case when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint1"]/string/text()') IS NOt NULL
THEN 'sellingpoint1'
end) as testsellingpoint1,
(case when xmltype(pr.attributes_de_de).extract('//attr[@name = "SellingPoint2"]/string/text()') IS NOt NULL
THEN 'sellingpoint2'
END
) as testsellingpoint2
FROM product pr WHERE pr.defaultproductvariationid =(SELECT prv.uuid FROM productvariation prv WHERE prv.uuid = '3rep_vEBP6IAAAE83REjnPbb' AND pr.typecode='16')