Awhile back I was getting help with what I call some complex queries. While most of the issues were resolved at the time, one was not and its resurfaced. In reference to thread 701-1351569(last couple posts) I have a query:
SELECT A.LocalUnitCd, A.LocalUnitType, A.CountyCd, L.LastAuditDate, A.FiscalYear AS LastFiscalYear
FROM dbo_localUnitAudit AS A INNER JOIN [SELECT LocalUnitCd,LocalUnitType, CountyCd, MAX(auditreceiveddate) AS LastAuditDate
FROM dbo_localUnitAudit GROUP BY LocalUnitCd, LocalUnitType, CountyCd
]. AS L ON (A.LocalUnitCd = L.LocalUnitCd) AND (A.AuditReceivedDate = L.LastAuditDate) AND (A.LocalUnitType = L.LocalUnitType) AND (A.CountyCd = L.CountyCd)
WHERE (((A.LocalUnitType)="2"));
Which is showing me how to obtain some good information that I was able to use in determining when someone sent in their audit and when it was due. At the time I asked, how then would I be able to use this logic to then pull out the MOST RECENT FISCAL YEAR, or even a given FISCAL YEAR, like 2006. I know I have a local unit who was suppose to file an audit in Fiscal Year 2006, but did not file. I need to be able to compute WHEN the audit was due, and show that they did not file the audit for Fiscal Year 2006.
It was suggested in the previous thread I replace the INNER JOIN above with a LEFT JOIN. That does not quiet do it because I don't have an audit received date.
Can someone please help me....
SELECT A.LocalUnitCd, A.LocalUnitType, A.CountyCd, L.LastAuditDate, A.FiscalYear AS LastFiscalYear
FROM dbo_localUnitAudit AS A INNER JOIN [SELECT LocalUnitCd,LocalUnitType, CountyCd, MAX(auditreceiveddate) AS LastAuditDate
FROM dbo_localUnitAudit GROUP BY LocalUnitCd, LocalUnitType, CountyCd
]. AS L ON (A.LocalUnitCd = L.LocalUnitCd) AND (A.AuditReceivedDate = L.LastAuditDate) AND (A.LocalUnitType = L.LocalUnitType) AND (A.CountyCd = L.CountyCd)
WHERE (((A.LocalUnitType)="2"));
Which is showing me how to obtain some good information that I was able to use in determining when someone sent in their audit and when it was due. At the time I asked, how then would I be able to use this logic to then pull out the MOST RECENT FISCAL YEAR, or even a given FISCAL YEAR, like 2006. I know I have a local unit who was suppose to file an audit in Fiscal Year 2006, but did not file. I need to be able to compute WHEN the audit was due, and show that they did not file the audit for Fiscal Year 2006.
It was suggested in the previous thread I replace the INNER JOIN above with a LEFT JOIN. That does not quiet do it because I don't have an audit received date.
Can someone please help me....