The attached application has script working correctly only for few userids. The data gets correctly reduced for few userids for both tables correctly, while for two userids, it reduces the second table incorrectly.
Thanks for your time Sunil. The mistake was I have typed in the field values in both the tables differently(read: incorrectly). The requirement is that the two fields though have same values, are part of two different models in the same application. The two models are not LINKED. In such a scenario I was trying out this sample.