[db] Fixed a bug in match transaction count

+ The relationship between grep results and transactions is many-to-many
+ Since we are trying to count the number of transactions with atleast one match,
we must group the results by transactions to avoid multiple entries of same transaction