Incorrect syntax near '=' error that I can't solve
Options
- 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
WITH isos AS
(
SELECT DISTINCT
Name,
CAST(RecordingTime AS DATE) AS testDate,
LOWER(TestType) AS testType,
CASE
WHEN LOWER(TestTypeName) = 'slppf' OR LOWER(TestType) = 'rsaip' THEN 'ankle iso push'
WHEN LOWER(TestTypeName) = 'slsquat' OR LOWER(TestType) = 'rskip' THEN 'knee iso push'
WHEN LOWER(TestTypeName) = 'slhipext' OR LOWER(TestType) = 'rship' THEN 'hip iso push'
ELSE LOWER(TestTypeName)
END AS testTypeName,
`Peak Vertical Force / BW` AS peakVerticalForce
FROM
my_table
)
SELECT *
FROM isos
WHERE testTypeName = 'hip iso push'