Numerous SQL Fixes esp. for the RAG Report