嘗試在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)(逗號分隔值)而不是多行的列?