How can I correctly implement a conditional WHERE clause using a parameter in SQL

join shbcf.ru