Why this join does not work?

Hello

I am having an issue with a join, can you help me please?

SELECT tbl1.C1 FROM T1 tbl1
INNER JOIN (SELECT C1, MIN(C2) FROM T2 WHERE C3=1 GROUP BY C1) tbl2 ON tbl1.C1=tbl2.C2

I get an error when trying to reference the inner selection as tbl2.

How can I do it please?

tbl2.C2
should come from the inner query
to be able to use it in the outer join

You mean the below?

SELECT tbl1.C1 FROM T1 tbl1
INNER JOIN (SELECT C1, MIN(C2) FROM T2 tbl2 WHERE C3=1 GROUP BY C1) ON tbl1.C1=tbl2.C2

It does not seem to work either!

Derived tables, views etc require names for all their columns.
I suspect the error told you this.
RTFI

MIN(C2) as MinC2

1 Like

select * from ( select c1 , c2 from table25 ) xyz join table2 on xyz.c2 = table2.c2

1 Like