I tried your suggested code and it didn't work too. But like Naomi suggested the UDF was creating the problem. I put the 2 fields involved in the UDF in the GROUP BY and it is now working.
Thanks.
Regards Bhavbhuti ___________________________________________ Softwares for Indian Businesses at: http://venussoftop.tripod.com ___________________________________________ venussoftop@gmail.com ___________________________________________