Posted on 2011-10-03
Hi, I'm trying to do this.
Have two tables Tbl_ServiceLevels, Tbl_AlarmServiceAgreements
Tbl_ServiceLevels has fields ServiceLevel and RenewalDate
Tbl_AlarmServiceAgreements has many fields we want to return including a ServiceLevel field
We want to get the ServiceLevel field for the max Renewal Date
-Then use that to return all the relevant fields from Tbl_ServiceLevels where fields ServiceLevel = that ServiceLevel string name found above.
Can do this in two different sql statements easy enough, but we plan on running thousands of times, and therefore want to optimise time.
Here are the two sql statements we want to nest
WHERE (ServiceLevel = '???')
SELECT MAX(RenewalDate) AS Expr1, ServiceLevel
WHERE (AlarmRef = 311)
GROUP BY ServiceLevel
ORDER BY Expr1 DESC
Can anyone guide in how to nest?