Is there any way for a model to 'do math' on RAG material?

Hi, thanks in advance for your input.

I have a data set that would work well in an RAG application. However, my users would like to not only get the information directly contained in the documents, but also would like to ask summary statistics of that information. For example, I have a collection of place names and the county those places are in. My users would like to query things such as “How many places are in King County?”. That doesn’t work (or at least I haven’t gotten it to work) in a ‘normal’ RAG setup because the answer to that question is not contained in the data.

Finetuning does not seem like the correct solution here (correct me if I’m wrong). I have also investigated text-to-sql (and text-to-csv in langchain), but my data is stored across multiple DBs (of multiple flavors).

Any ideas of how to proceed here? Thanks.