It is not a good security practice to allow any SQL statement to be fed in via inputs as raw SQL from the front end.
You could provide a UI where they can create parameters so that in the back end, these could be fed to parameterised queries. Then you could create a condition builder that essentially allows them to build their query but through UI instead of SQL.
So for example, if one of the queries they might write is SELECT * FROM Products WHERE Id = 1
, you could instead provide a UI on which they can create a parameter called Id
and give it a value of 1. Then they could have a dropdown to pick from a list of available tables, followed by other UI which allows them to construct their WHERE clause.
It's pretty heavy compared to just passing through the raw SQL, but it would allow you to control what you put in your query in the back end, which would of course be using parameters.
Parameterised queries are standard security practice for any inbound requests to DBs using SQL from the front end. Here's a basic intro to them using SqlCommand
in C# and VB.NET