I don't know how you'd do that in a query (or if it is even possible. What I would do is go through the table and build a dictionary using val(b1) & "," & val(b2) as the key and the frequency as the value. Then I would scan the dictionary and pick the keys with the highest frequencies. Implementation depends on the language you are using.
Sometimes, even if you can do it in a query, the query can be so convoluted that it is cleaner to do it in code.