[英]string_agg ignore specific value in column
SELECT string_agg(col, ',') as cols
FROM (
SELECT
json_field_name || ' AS ' || csv_field_name as col
FROM pricing.sandbox_configurations
WHERE include is true
ORDER BY sequence_id
) a
这样做会给我这样的结果
product_cd AS product_cd,product_name AS product_name
但是,如果我想忽略值名称 product_name 并且只想将列值的 rest 作为字符串返回怎么办。
我将如何实现这一目标?
您可以通过在 where 子句中删除具有此值的 riws 来忽略product_name
。
SELECT string_agg(col, ',') as cols
FROM (
SELECT
json_field_name || ' AS ' || csv_field_name as col
FROM pricing.sandbox_configurations
WHERE include is true
and <>'product_name'
ORDER BY sequence_id
) a
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.