Is it possible to create a where clause that only executes if the condition exist (not null)?
Where is used to specify a condition. However, in one instance this condition is NULL. Is it possible if the where condition is not met to make the code execute as if the where clause wasn't there.
Right now I am using a dynamic form of SQL on snowflake (snowflake). You can create control variables that is similar to the DECLARE @ statement from dynamic SQL.
My query shows the average score people got on certain answers. I use the person's name column and then a dynamic type variable that can be chosen and changed.
WHERE person = {PERSON}
{PERSON}, represents all the people's names (personA, personB, etc). When a certain person is selected it acts as if
WHERE person = 'personA'
When no one is chosen the query will not run as the WHERE statement will not be met. I would like to just show the total averages instead of just an individual person's when nothing is chosen.
Perhaps it's possible to make a case statement that if exist{PERSON} then WHERE person = {PERSON}, ELSE - exits case and code acts as if where statement wasn't there
Aucun commentaire:
Enregistrer un commentaire