nrad
nrad

Reputation: 93

How to solve: Scalar subquery produced more than one element

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

Upvotes: 0

Views: 3920

Answers (1)

Mikhail Berlyant
Mikhail Berlyant

Reputation: 173028

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)

Upvotes: 3

Related Questions