I have a very simple query that gets a field to use as constraints in another query.
FROM apcType T
INNER JOIN apcAttribute a on A.T = T.RIN
WHERE T.Name like '%Sales'
The results of the first query are used in the following query where it is bolded and marked with and <<<<========
SELECT AP.Arg2, AP.Arg3, M.Parcel,
M.Serial, M.Name, M.Acres, M.District,
V.YearBuilt, V.Code, V.Size,
FROM TRValue V1
WHERE V1.Year = V.Year and V1.Parcel = V.Parcel and
SUBSTRING(V1.Code, 1, 1) = 'L'
FROM TRValue V
INNER JOIN APList AP on AP.TRValueRIN = V.RIN
INNER JOIN TRMaster M on M.Year = V.Year and M.Parcel = V.Parcel
WHERE M.Year = 2012 and M.Deleted = 0
and M.Parcel between '00-0000-0012' and '00-9999-9999'
and M.District between 1 and 98
and AP.Arg2 between 76340 and 77770
and AP.AttributeRIN in (1900,1901) --<<<<=========
ORDER BY M.Parcel
My question is How can I fold the first query into the second?