slno state district company
1 a ab abc
2 a ab ac
3 a ab abc
4 a ab abc
5 a ab abc
6 a ab ac
output
state district company sumzz
a ab abc 4
a ab ac 2
what i have tried
select state,district,company,sum(company) as sumzz from company
how to achieve this display the last row based on distinct company?
And what’s wrong with this approach: