Hi All,
I want to sum the value of all parameters grouping by event and then arrange the score in descending order. How can I do so.
with t as
(select 'Asthma' as event, 1 as f1, 0 as f2 , 0 as f3, 1 as f4 from dual union
select 'Fever',1,1,1,1 from dual union
select 'Fever',1,0,0,1 from dual union
select 'Asthma',1,1,1,1 from dual union
select 'Asthma',1,1,1,1 from dual union
select 'Asthma',0,1,1,1 from dual union
select 'Acidity',1,0,1,0 from dual union
select 'heart attack',1,1,1,1 from dual)
select t.* , sum(f1+f2+f3+f4) as T_score from t
group by event, f1,f2,f3,f4
order by 1
My Output
| EVENT | F1 | F2 | F3 | F4 | Overall_score |
| Asthma | 2 | 2 | 2 | 3 | 9 |
| Fever | 2 | 1 | 1 | 2 | 6 |
| heart attack | 1 | 1 | 1 | 1 | 4 |
| Acidity | 1 | 0 | 1 | 0 | 2 |
| | | | | |