Hi Adam,
In the shared SQL query, I observed that the last statement of the where clause section is defined incorrectly (maybe you missed that) as shown below
{UploadScorecardElement8}.[D4220]) // the Boolean/conditional expression is incomplete
instead it should be something like this
{UploadScorecardElement8}.[D4220] <> '')
Hope this helps you!
Kind regards,
Benjith Sam