I have data like this:Code as varchar, Amount as numeric(3,0)Code Amount A 100B 150C 200D 250E -100F -150G -200H -250I 0
I have parameter @overbudget as charif @overbudget = '1', then the result is (E,F,G,H). if @overbudget = '0', then the result is (A,B,C,D,I).This is my query.SELECT * FROM TEST GROUP BY CODE, AMOUNT HAVING(CASE WHEN ISNULL(@Overbudget,'') = '1' THEN AMOUNT ELSE NULL END) < 0OR(CASE WHEN ISNULL(@Overbudget,'') = '0' THEN AMOUNT ELSE NULL END) > 0
Is there any simple query to select my data? Thank you for your help.