I have a table
CREATE TABLE test1 (
CREATE VIEW view1 AS
WHEN D_ in ('false') THEN LEFT(A_, CHARINDEX('(', A_) -1)
END AS D,
WHEN C_ IS NOT NULL THEN '0'
END AS C
Column 'test1.A_' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
_A is used in the
LEFT(A_, CHARINDEX('(', A_) -1) you have to include it in the
GROUP BY. It does not matter that it is in the
CASE. The only situation that we do not have to add the attribute to
GROUP BY is when the attribute is part of an aggregate function.