Created
March 11, 2014 23:17
-
-
Save optilude/9497038 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT `planDays`.`projectId` AS `projectId`, | |
`planDays`.`allocationId` AS `allocationId`, | |
ROUND(SUM(`planDays`.`hours` * | |
(SELECT `rates`.`cost` | |
FROM `rates` | |
INNER JOIN `teamMemberGrades` ON `rates`.`id` = `teamMemberGrades`.`rateId` | |
AND `teamMemberGrades`.`teamMemberId` = `planDays`.`teamMemberId` | |
WHERE `teamMemberGrades`.`startDate` IS NULL | |
OR `planDays`.`day` >= `teamMemberGrades`.`startDate` | |
ORDER BY `teamMemberGrades`.`startDate` DESC LIMIT 1)), 2) AS `value` | |
FROM `planDays` | |
INNER JOIN `allocations` ON `planDays`.`allocationId` = `allocations`.`id` | |
INNER JOIN `projects` ON `allocations`.`projectId` = `projects`.`id` | |
INNER JOIN `teamMembers` ON `planDays`.`teamMemberId` = `teamMembers`.`id` | |
WHERE `projects`.`portfolioId` = 1 | |
AND `teamMembers`.`thirdParty` = 1 | |
AND `planDays`.`day` <= '2013-01-01' | |
GROUP BY `planDays`.`projectId`, | |
`planDays`.`allocationId` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment