Viktor
The quick and dirty method would be to pass the subquery as a string,then execute the subquery in the function.
Will T