This is how a table is presented
SELECT RequestsID, Country, Activity,
[People needed (each day)], [Start date], [End date]
FROM dbo.Requests
There will be a lot of requests, and I would like to sum up the "People needed" per day (!), not as Between Start- and End date.
Also I would like to group by country, and have the possibility to set between which dates I want to get data.
Some days might be empty regarding needed people (0), but the Date should be presented anyway. Note that there can be several requests pointing out the same Dates, and the same Country - but the Activity is then different.
The query should be like (well, it´s not SQL as you can see, just trying to show the logic)
From Requests,
show Country and SUM 'People needed'
where (column not in Requests table-Date) is a Date (will be
a number of dates, I want to set the scope by a Start and End date)
and Requests.Country is @Country
(and the Date(s) above of course is between the Requests Start date and End date...)
And from (a non existing table...?) show Date
Group by Country
I would like to see something like this:
Date Country People needed
06/01/2010 Nigeria 34 // this might be from three different Requests, all pointing out Nigeria. People needed might be (30+1+3 = 34)
06/02/2010 Nigeria 10
06/03/2010 Nigeria 0
06/04/2010 Nigeria 1
06/05/2010 Nigeria 134
06/01/2010 China 2
06/02/2010 China 0
06/03/2010 China 14
06/04/2010 China 23
06/05/2010 China 33
06/01/2010 Chile 3
06/02/2010 Chile 4
06/03/2010 Chile 0
06/04/2010 Chile 0
06/05/2010 Chile 19
How would you do it?
NOTE: I would like to see some kind of example code, to get started :-)