Thanks for your replay and sorry for my mistaks in my post.
As you said, the clssess I pass is dynamic. I used a listbox (selection mode - mulltiple)for selecting the classes. Each time the number of classes is different according to listbox selection.
I tried using the query you provided. But I got the result as null. would you please help me to solve it.