ERROR: subquery must return only one column in PostgreSQL

123 Views Asked by At

I'm trying to write a select statement that requires the stored procedure in PostgreSQL. But, it fails by this error: ERROR: subquery must return only one column. The query is as follow:

select(
(select 
'q1_parasiticide_carton_rebate' as rewardName,
case when  q1_parasiticide_carton_rebate is null then CAST(0 as VARCHAR)
else cast(coalesce(q1_parasiticide_carton_rebate,0) as VARCHAR(10)) end as rewardAmount
from temptable 
),
(select 
'q2_parasiticide_carton_rebate' as rewardName,
case when  q2_parasiticide_carton_rebate is null then CAST(0 as VARCHAR)
else cast(coalesce(q2_parasiticide_carton_rebate,0) as VARCHAR(10)) end as rewardAmount
from temptable
))
from temptable;

Please help me with this.

0

There are 0 best solutions below