Hi @davidgs, welcome to Meta
Have you tried using an LLM like ChatGPT? It has reasonable understanding of Discourse and has been fairly reliable when I also needed to make data explorer queries.
I often write my prompts like “Write a Discourse data explorer query which returns x,y,z from a,b,c where …” and end up with something pretty reasonable.
In the top right of this page you might also see a little robot icon like below.
If that’s the case you could also try the AI Helper Bot that’s integrated with Meta