Are you experienced in programming, how is the best way you'd want to enter a query like that - could you do it in python or would you prefer SQL?
I have found a thread discussing querying the data on the blockchain -
https://bitcoin.stackexchange.com/questions/61252/how-to-learn-to-query-the-block-chainThere are also a few implementations of python chain parsers you might want to look at, for example -
https://github.com/alecalve/python-bitcoin-blockchain-parser (but I haven't tested this).
If you had the time or money, you could also commission someone else to do this - you could also look at APIs that might be available from block explorers too.
I couldn't find commands for querying this in bitcoin core itself looking at the help menu but that might not mean there isn't one, it's just not well documented on the console start screen.