Here is the problem I'm trying to solve. I have 3 database tables - Sales, Customer and Time. One sales record is associated with one customer record and one time record. I want, only in 1996, to look at the total sales by region (the client is tied to a certain region), for the following further divisions: on holidays, weekends, working days and days off. Here is a query that I still have rude with what I'm trying to add in the comments.
var totalSales =
from s in sales
where s.Time.Year = 1996
group s by s.Customer.Region into g
select new { Region = g.Key,
Holidays = g.Sum(s => s.Total_Amount),
NonHolidays = g.Sum(s => s.Total_Amount),
Weekdays = g.Sum(s => s.Total_Amount),
Weekends = g.Sum(s => s.Total_Amount)};
To do this, I will need to be able to further limit the results within each close. Is it possible? Do I need to restructure the request? I could, of course, accomplish this by breaking it into 4 separate queries, but it would be very nice to do this in one.
Thank.
source
share