You need another parameter to receive the output value in the Execute clause.
EXEC SP_TestOutput @GroupNum=1001 , @max_value=@max_value_final OUTPUT Select ID From mytable Where Col2 = @max_value_final
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.