Karthik could you brief us upon the requirement a bit??...It won't be that much of an effort......Plus you might get opinions that might make this requirement easier for you cause in any given case this approach is going to kill your performance completely. 😉
PS: Don't forget to set up some sample data and show us a working example. 😀