posted 14 years ago
I have a requirement to find the max of purchase for the user and then find the avg of those max records retrieved. So i created a procedure which joins multiple tables and hence calling the below function for one of those columns.
While executing this part of function in sql prompt, i am getting blank output, although the query when executed outside the function gives 45 records.
Also, please let me know how can i find the avg of all the values from max(purchase) and put that to avgsales variable and return that to the procedure.