variables used in inner queries
Posted
by wcpro
on Server Fault
See other posts from Server Fault
or by wcpro
Published on 2010-01-05T23:19:10Z
Indexed on
2010/04/13
9:03 UTC
Read the original article
Hit count: 486
im trying to build a query that has something like this
select
id,
(select top 1 create_date from table2
where table1id = t1.id
and status = 'success') [last_success_date],
(select count(*) from table2
where table1id = t1.id
and create_date > [last_success_date]) [failures_since_success]
from table1 t1
as you can see the [last_Success_Date] is not within the scope of the second query, and i was wondering how i could access that value in other queries without having to rerun it?
© Server Fault or respective owner