Hello all, I am a newbie to Sybase and This is an emergency requirement of my client..

I need to write a function to populate a temporary table.

My Query is this way:

select p.product,max(p.price)as price
into #temptable
from owner.products p,
(select product,max(date) from owner.products where product = 'mouse' group by product) q
where p.product = q.product and
p.date = q.date
group by p.product

This is my query..where in I am populating the data into a table named "temptable"

I need to implement this little query by using a function..
I would be passing a parameter for 'mouse' through the function as Input..
Please help me..