views:

21

answers:

1

The partial select statement is:

SELECT t1.Column1, t1.Column2, **"Column3"** = dbo.FunctionName(Column1, Column2)
  FROM Table1 t1

Now I wanted to left join Table2 in above query but join needs to be "Column3" = Table2.Column3; something like as below query which does not work and how to achieve that.

SELECT t1.Column1, t1.Column2, Column3 = dbo.FunctionName(Column1, Column2),
       t2.Abc, t2.bcd
  FROM Table1 t1 LEFT OUTER JOIN Table2 t2 ON t2.Column3 = ????

Thanks in advance.

A: 

Did you try

SELECT 
          t1.Column1, 
          t1.Column2, 
          Column3 = dbo.FunctionName(Column1, Column2)
          t2.Abc, t2.bcd
FROM
          Table1 t1 
          LEFT OUTER JOIN Table2 t2 
          ON t2.Column3 = dbo.FunctionName(t1.Column1, t1.Column2)

This should also work

SELECT 
      t1.Column1, 
      t1.Column2, 
      t1.Column3,  
      t2.Abc, 
      t2.bcd
 FROM 
    Table2 t2 LEFT JOIN JOIN 
 (SELECT t1.Column1, t1.Column2, Column3 = dbo.FunctionName(Column1, Column2)
  FROM Table1 t1) t1
  ON t2.Column3 = t1.Column3
Conrad Frix