I have a similar situation.
I have a web form in which I have different search fields. I wanti to do a search for some of these fields and then view a report with the search results. But I sould create the query dinamically because if I don't select a filter that field shouldn't be included in the query.

for example:
I search for field name and I don't insert anything inside surname field. the query is:
select...