Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I assume that Start Date and End date are formatted as Date time or Date.</p> <p>I'm not sure if you are trying to determine if the start date records fall within the past 3 months or the end date records.</p> <p>Also you'll need a limit to determine the Sum(Allocation %). What unique records are you wanting to sum. Since you want to Sum Allocation % and then select only the ones that are greater than 100, you have to figure out which ones to pull then to sum.</p> <p>You'll want to accomplish this using a With statement or creating sub "tables" (queries) that pull the information you want in stages. I'll present the subquery statements.</p> <p>Written for Sql-Server 2008 R2</p> <p>First Select data that is within the Past 3 months</p> <pre><code>Select ResourceAssignmentID, ResourceID, [Assigned To], [Allocation %] From ResourceAssignment Where [Start Date] &gt;= dateadd(Month,-3,Now) </code></pre> <p>Then using this data you want to Sum the Allocation %. (I am assuming based on the combination of the 2 foreign keys)</p> <pre><code>Select Query1.ResourceID, Query1.[Assigned To], sum(Query1.[Allocation %]) as Sumofallocation From (Select ResourceAssignmentID, ResourceID, [Assigned To], [Allocation %] From ResourceAssignment Where [Start Date] &gt;= dateadd(Month,-3,Now)) Query1 Group By Query1.ResourceID, Query1.[Assigned To], sum(Query1.[Allocation %]) </code></pre> <p>You may be able to add the Where statement before the group by to filter out for your >100 requirement, but I would just add another Select statement to pull it all together</p> <pre><code>Select * From (Select Query1.ResourceID, Query1.[Assigned To], sum(Query1.[Allocation %]) as Sumofallocation From (Select ResourceAssignmentID, ResourceID, [Assigned To], [Allocation %] From ResourceAssignment Where [Start Date] &gt;= dateadd(Month,-3,Now)) Query1 Group By Query1.ResourceID, Query1.[Assigned To], sum(Query1.[Allocation %]) ) Query2 Where Query2.Sumofallocation &gt; 100 </code></pre> <p>Also, it seems like you are working on a project management type program. Would Microsoft Project not work? You would be able to see who's over allocated in whatever time-frame you wished. If you have multiple projects, you could just merge them into one large Project file and see it that way...</p> <p>Anyway, I hopes this helps. The SQL might not be perfect, but it should point you in a workable direction.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload