I want to make a query using a conditional to select a clause for filter.
Something like this.
SELECT Id,name,last_name,submitDate,lastvisitDate
from Visitor Where if(submitDate is not null) begin submitDate >= @dateFrom end
and if(submitDate is not null) begin submitDate < @dateTo end
but I need for example if @dateTo is null this variable doesn’t participate on the filter query
You can apply
ISNULLto@dateToand thus default it to some really distant future date, like30000101: