Allow switching between select distinct and select all query