This one is doing my head in. I sure hope someone can helpI have 2 tablesLocations loc_Location_ID PKand Activityact_Activity_ID PKact_Location_ID FKact_Activity_Date_End (datetime)What I need to do is return a list of locations with the Activity date of the latest act_Date for that location. I should note that I have tried this as a testSELECT TOP 1 act_Activity_Date_End, loc_Location_ID FROM LocationINNER JOIN Activity on act_Location_ID = loc_Location_IDORDER BY act_Activity_Date_End DESC
This test works, but I already have a 'TOP' in my main query. Seems you can't use TOP twice. I tried this as a 2nd test and it fails for that reason SELECT TOP 1 pro_Prospect_ID, TOP 1 act_Activity_Date_End, loc_Location_ID FROM LocationINNER JOIN Activity on act_Location_ID = loc_Location_IDINNER JOIN Prospect on pro_Location_ID = loc_Location_IDORDER BY act_Activity_Date_End DESC
Help please!