尝试在Postgresql中用4个返回表(多行)的参数创建函数。 参数:in_customer_id, in_start_date, in_end_date, in_risk_flag
返回多个行作为逗号分隔值,当语句为
我正在使用该功能的SQL查询:我得到
select * from customer as k
where k.customer_id IN (case when $1 = 0 then (select distinct(customer_id) from customer)
when $1 != 0 then $1
end)
and k.start_date >= $2
and k.end_date <= $3
and k.risk_flag IN (case when $4 = 0 then (select distinct(risk_flag) from customer)
when $4 != 0 then $4
end)
错误是错误[21000]:more than one row returned by subquery used as an expression
。
有没有办法从case语句返回(1,2,3,4,5,6)(逗号分隔值)而不是多行的列?