[quoted text, click to view] >>
WITH temp (var1 var2) as
(
select field1, field2
from table1
)
<<
above syntax's equivalent in sql server is:
select field1 as var1,field2 as var2 into temp from table1
--the query remain the same :
select tb1.field2, tb2.var2
from
temp as tb1,
table2 as tb2
where
tb1.var1 = tb2.field1
--using ansi syntax you can have query as:
select tb1.var2, tb2.var2
from temp as tb1 join table2 as tb2
on tb1.var1 = tb2.field1
--without creating the temporary table you can make use of SELECT statement
as an inline view as follows:
select tb1.field2, tb2.var2
from (select field1,field2 from table1) as tb1 join table2 as tb2
on tb1.field1 = tb2.field1
--
Vishal Parkar
vgparkar@yahoo.co.in | vgparkar@hotmail.com