try this, select person , name, sum(tot_values) from ( select person, case when name = 'a' then 'a' else 'others' end as name , sum(tot_values) as tot_values from test_tabb group by person,name ) X group by person,name order by person desc, name
M
mnatarajakumaran
@mnatarajakumaran
Posts
-
SQL Query Problem -
Query slowed upHi, Don't use Distinct key word its will reduce the performance. Without distinct also given the same result because you are using group by class. So no need distinct key word. Just remove and check it.