Look at the following UPDATED scenario (sorry that I fooled you with the un updated version - hope it will be clearer now) - it may seem simple to some people, and hopefully it is!
Explanation: Every row is a Request. Allocated is the number of people requested to an activity, total is the total amount of people for this country available for activities, and diff is... the diff between the total amount of people and Max people used. And "Max people used..." is what everything else hangs on.
SHOULD BE:
COLLECTION OF REQUESTS WITH DIFFERENT START- AND END DATES
COUNTRY START DATE END DATE ALLOCATED TOTAL Max people used for this period DIFF
China NOV 1 NOV 2 2 5 4 1
China NOV 3 NOV 4 2 5 4 1
China NOV 1 NOV 4 2 5 4 1
MY RESULT:
COLLECTION OF REQUESTS WITH DIFFERENT START- AND END DATES
COUNTRY START DATE END DATE ALLOCATED TOTAL Max people used for this period DIFF
China NOV 1 NOV 2 2 5 4 1
China NOV 3 NOV 4 2 5 4 1
China NOV 1 NOV 4 2 5 6 -1
(For NOV 1 to NOV 4 "Max people used..." sums ALLOCATED as 2+2+2 instead of 2+2...)
And here you can see how I got "MY RESULT"
SELECT DISTINCT Country.Country,
-- here comes the sum that doesn´t work...
SUM(Requests.[Amount of people per day needed]) AS [Max people used for this period]
FROM Country INNER JOIN
Requests ON Country.CountryID = Requests.CountryID
WHERE (Country.Country = 'China')
AND (Requests.[End date] >= @busyStartDate)
AND (Requests.[Start date] <= @busyEndDate)
GROUP BY Country.Country
"Max people used..." is the thing not working here - can I get that right, the rest will follow by business logic that you don´t see here :-)
UPDATE
Actually, I have given this up - didn´t get it to work in spite of good answers. Instead I did this (with the help of others, of course) to finally reach my goal ;-)