I have a sproc for returning LaborHours that has a User Defined Function for a row source which returns a sum of Fringe costs, usually 4 fringe rows for every LaborHours row in sproc. I want to then add the LaborHours with the sum of the Fringe costs as another column but I have to rerun the Function and it makes the query time go from 7 seconds to more than twice that. Seems to me if I already calculated the Fringe costs I could store them in a variable and then add the variable to the LaborHours for a total column.
Here is an excerpt from my sproc:
hs.LAB_CST_AMT AS TotalLaborCost,
EY) AS TotalFringeCosts, --This returns the sum of fringe costs,
EY) + hs.LAB_CST_AMT AS TotalCosts, --have to rerun the function and add it to the laborcost
Is ther a way to assign the fringe costs to a variable and reuse it?