You would need to know the exact question being asked in order to determine the join type. You could join tableA to tableB on a related attribute using an inner, left outer, right outer or cross join. All 4 would yield different results (depending on the data) each appropriate to a different question.
You need to retrieve the question in a way that can be translated to SQL. If a user asked a question in plain English you might be able to code some sort of translation tool. A query building GUI is essentially another way to retrieve the question and translate it to SQL.
A simpler approach would be to use pre-defined views and add build the SELECT, WHERE, GROUP By, ORDER BY etc clauses based on information from the user.