"JobStatus" AS "Job Status",
"Division" AS "Division",
"DepartmentName" AS "Department",
"ProcessName" AS "Phase",
concat("Division", "ProcessName") AS "Capacity Phase Machining",
concat("Division", "DepartmentName") AS "Capacity Phase Labor",
"Customer Name" AS "Customer",
"Job Number" AS "Network",
"DeptEstStart" AS "Scheduled Start Date",
"DeptEstEnd" AS "Scheduled End Date",
find_max_value("DeptEstEnd", current_date()) AS "Capacity End Date",
"DeptActStart" AS "Actual Start Date",
"DeptActEnd" AS "Actual End Date",
"ProcessEstHours" AS "Budgeted Hours",
"ProcessActHours" AS "Hours Consumed",
"ProcessEstHours" -"ProcessActHours" AS "Remaining Hours",
"ProcessEstHours" * (1 -"DeptPercentComp") as "Remaining Hours POC",
find_max_value(to_integer(date_diff("DeptEstEnd", current_date())), 1) AS "Remaining Days",
("ProcessEstHours" * (1 -(find_max_value("DeptPercentComp", ("ProcessActHours" / "ProcessEstHours"))))) / find_max_value(to_integer(date_diff("DeptEstEnd", current_date())), 1) AS "Hours p/Day Remaining",
(1 -"DeptPercentComp") * "ProcessEstHours" / find_max_value(to_integer(date_diff("DeptEstEnd", current_date())), 1) AS "Hours p/Day Remaining_POC",
("ProcessEstHours" -"ProcessActHours") / find_max_value(to_integer(date_diff("DeptEstEnd", current_date())), 1) AS "Hours p/Day Remaining_Formula",
("ProcessActHours" / "ProcessEstHours") * 100 AS "% Of Budget Consumed",
"DeptPercentComp" * 100 AS "POC",
"QA Lead",
"Build Lead",
"PM",
add_date("DeptEstEnd", ROUND(("DeptEstHours" -"DeptActHours") / -24)) AS "Latest Start Date",
find_max_value(add_date("DeptEstEnd", ROUND(("DeptEstHours" -"DeptActHours") / -24)), current_date()) AS "Capacity Start Date",
to_integer(date_diff("DeptEstEnd", find_max_value(add_date("DeptEstEnd", ROUND(("DeptEstHours" -"DeptActHours") / -24)), current_date()))) AS "Remaining Scheduled Days"
FROM "Eagle_SAP_PlanHours"
JOIN "Eagle_AllHoursReport" ON "Eagle_SAP_PlanHours"."Job Number"="Eagle_AllHoursReport"."Job Number"
WHERE "JobStatus" IN ( 'In Process' )