A full new query builder would be a big task. I have been working on enhancing the existing and undermaintained Configurable reports plugin. I have a branch that pulls in the tables and columns from the underlying install.xml files and offers "intellisense" when creating sql queries. This works quite nicely but I would like to do more, e.g. put the { and } round table names and understand the PK/FK relationships. However to do that means transitioning to CodeMirror6 as the CodeMirror5 I have is obsolete.
https://github.com/marcusgreen/moodle-block_configurablereports/tree/sqlhints
If anyone is interested.
https://github.com/marcusgreen/moodle-block_configurablereports/tree/sqlhints
If anyone is interested.