Need to use query column value in nested subquery
Posted
by Dustin
on Stack Overflow
See other posts from Stack Overflow
or by Dustin
Published on 2010-05-24T18:11:12Z
Indexed on
2010/05/24
18:21 UTC
Read the original article
Hit count: 200
sql
It seems I cannot use a column from the parent query in a sub query. How can I refactor this query to get what I need?
dbo.func_getRelatedAcnts
returns a table of related accounts (all children from a given account). Events and Profiles are related to accounts.
SELECT COUNT(r.reg_id)
FROM registrations r JOIN profiles p ON (r.reg_frn_pro_id = p.pro_id)
JOIN events e ON (r.reg_frn_evt_id = e.evt_id)
WHERE evt_frn_acnt_id NOT IN (SELECT * FROM dbo.func_getRelatedAcnts(p.pro_frn_acnt_id))
© Stack Overflow or respective owner