Why is this SQL code throwing an error associated with the NULL?
CASE WHEN `hire_year` = ‘2022’ THEN `percent_value` WHEN `hire_year` != ‘2022’ THEN NULL END
Is there a particular reason you need them to be null? If they are numeric values you can set them to = 0 and if they are strings you can set them to = ‘’
it looks like you are working with percentages, so could you just set it to = 0?
Is 2022 a column? Or is it a string value? You have the ` around both sides of it which is used for columns names. If 2022 is not a column, it will throw an error. If you are wanting to look for the string value 2022 then you should have single quotes around it.
Just use THEN ‘’ END
That solution is still throwing an error.
Hmm maybe just eliminate line 3 and replace it with ELSE ‘’
Is there a way to just set it to NULL?
Good catch @MarkSnodgrass, I was looking at it on my phone and the ticks appeared to be ' not `