I have an SQL query that I use to determine who is the director (or acting director) of a particular agency. The person with the lowest TeamID then lowest Ranking is who's in charge currently (this takes into account agencies who are between directors). Here is the current query:
Code:
SELECT L.*
FROM dbo_LDPE_Person AS L INNER JOIN [SELECT LDPE_LibraryID, Min(LDPE_TeamID+100*LDPE_Ranking) As MinRankTeam FROM dbo_LDPE_Person GROUP BY LDPE_LibraryID] AS M ON (L.LDPE_TeamID+100*L.LDPE_Ranking=M.MinRankTeam) AND (L.LDPE_LibraryID=M.LDPE_LibraryID)
WHERE LDPE_PersonType="Library Staff";
[code]
Unfortunately, yesterday morning I was working on another query that involved this one, and now neither query works. I didn't make any changes to the database itself, I was just doing a SELECT.
Any thoughts?
I've gone over it multiple times, unless I've really missed a typo, all the names are correct. And again, it was working fine.
Thanks!