0
votes

I have following query. In cte_2, I'm using result from cte_1. It gives me an error:Scalar subquery produced more than one element. How to solve it.

WITH cte_1 AS

(SELECT a,b,c FROM t1)


,cte_2 AS
 (SELECT
 ,(select a from cte_1) as a    
 ,d as fix  
 ,d.*
 FROM t2 AS cr
 LEFT JOIN t3 AS d
        ON cr.Date = d.Date)

 Select * from cte_2
1

1 Answers

1
votes

error:Scalar subquery produced more than one element. How to solve it?

Instead of (select a from cte_1) - use ARRAY(select a from cte_1)