Reputation: 477
I want to perform a specific task in where clause only if the source like "GOLD%" then SOURCE_SUB_CATEGORY like any ('WHITE%','YELLOW%').
SELECT t1,t2, t3 from table where <other conditions> and case when SOURCE="GOLD%" then SOURCE_SUB_CATEGORY like any ('WHITE%','YELLOW%') end group by 1,2,3.
This is throwing errors -"Syntax error, expected something like an 'END' keyword between the word 'SOURCE_SUB_CATEGORY' and the 'like' keyword". So all I am looking for is to perform only if source is gold then an extra where condition to select only if the source_sub_category is like any white% or Yellow%. I guess I should not use a case statement here I am ready to use any alternative too to perform this task.
Upvotes: 0
Views: 842
Reputation: 8703
So, first off, SOURCE="GOLD%"
is not valid.You want SOURCE LIKE 'GOLD%'
.
To handle your where statement, I would use something like:
where...
and (
(SOURCE LIKE 'GOLD%' and sub_source_category like any('WHITE%','YELLOW%'))
OR SOURCE NOT LIKE 'GOLD%')
Upvotes: 1