Incorrect syntax near '=' error that I can't solve
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 01:02 AM
Hi,
I'm receiving the error Incorrect syntax near '=' when I run simple queries like the example below. This only happens when I use a column created using a CASE statement in the WHERE clause. I can use any other column in the WHERE clause, including the original columns used to create the new column, and the query runs fine.
I'm sure this is a really simple one but it's escaping me at the minute. Any help would be greatly appreciated
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2024 04:57 AM
What jumps out to me at first is the backticks on `Peak Vertical Force / BW`, but I'm assuming that's just a column name and not an attempt at division.
Next that jumps out is TestType and TestTypeName being aliased as testType and testTypeName- spark by default is case insensitive with column names, which could be contributing to issues.
I don't see anything else that jumps out to me as fundamentally wrong, so next step is to just start tweaking/removing random things until it works and then re-adding to see where the line between broken/working is.
I'd start by removing the WHERE clause and seeing what shows up, and if that doesn't work strip back the columns selected and turn the WHEN...OR...THEN into a separate WHEN for each condition.

