I have a stored procedure where I need to return both function results and the average from both, how can I call them only once to get the result?
Select
get_valueX(jobId, c.id),
get_valueY(jobId, c.id),
(get_valueX(jobId, c.id) get_valueY(jobId, c.id)) / 2,
c.name
From candidate c
(Reduced the procedure code to only required code to see the problem, also jobId is an input variable from procedure)
CodePudding user response:
Select x, y, name, (x y)/2 As xy_avg
From (
Select
get_valueX(jobId, c.id) As x,
get_valueY(jobId, c.id) As y,
c.name
From candidate c
) As t;