1. The column in the select list is not valid because the column is not contained in an aggregate function or a GROUP by clause
A: When you specify group BY, all columns in any non-aggregate expression in the selection list should be included in the group by list, or the group by expression must exactly match the select list expression.
2. Use of the case and then else end syntax
Select
I.index_name,i.index_def,
SUM (case when w.years= and then W.actual_value else 0 end) as A1,
SUM (case when w.years= and then w.ranking else 0 end) as R1,
SUM (case if w.years= (2014-1) then W.actual_value else 0 end) as A2,
SUM (case if w.years= (2014-1) then w.ranking else 0 end) as R2,
From Bm_work W,bm_index I
where
W.indexdef_id=i.uuid and
W.ent_id= ' 2c90e4da49514c750149515eb56f0003 ' and w.summary_state=2
Group BY I.index_name,i.index_def;
This statement achieves such an effect
SQL Server Drip Accumulation