Is it possible to create some enumaration for 'a','b','test','123','blabla'
in following statement?
sum(case when col1 in ('a','b','test','123','blabla') then col2 end) as sum
I've tried to read it from letters_table
like this:
sum(case when col1 in (select letter from letters_table) then col2 end) as sum
but it told me Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
and following is not working fine for me:
DECLARE @letters varchar(10)
select @letters = letter FROM letters_table
sum(case when col1 in (@letters) then col2 end) as sum
because when I print the @letters
, there is just the last one 'blabla'