A CASE statement can only return one value, so the line for 'Maize' will not work.
The CASE statement would also be within the parenthesis.
WHERE B.ACCTSET IN (CASE
WHEN @AcctSet ='Maize' THEN '001X04'
WHEN @AcctSet ='Wheat' THEN '002X04'
ELSE '004X04'
END
)
If the results are fixed like in your example then you could create a table var and insert the records in to it based on your logic, then join on that or use it in your IN().
DECLARE @Values TABLE( [Value] VARCHAR(6))
IF @AcctSet ='Maize'
BEGIN
INSERT INTO @Values VALUE('001X04')
INSERT INTO @Values VALUE('010X04')
END
ELSE IF @AcctSet ='Wheat'
BEGIN
INSERT INTO @Values VALUE('002X04')
END
ELSE
BEGIN
INSERT INTO @Values VALUE('004X04')
END
/..snip../
WHERE WHERE B.ACCTSET IN (SELECT [Value] FROM @Values)