I have report data is that structured as followed:
RecID | ReportView1 | Name | Value | Total
1 | CURRENT_VIEW | 'Test1' | 10 | 20
1 | PROPOSED_VIEW | 'Test11'| 20 | 30
1 | POTENTIAL_SAVING_VIEW | null | null | 80
2 | CURRENT_VIEW | 'Test1' | 10 | 20
2 | PROPOSED_VIEW | 'Test22'| 25 | 35
2 | POTENTIAL_SAVING_VIEW | null | null | 70
3 | CURRENT_VIEW | 'Test1' | 10 | 20
3 | PROPOSED_VIEW | 'Test33'| 45 | 65
3 | POTENTIAL_SAVING_VIEW | null | null | 90
I want to reorder based on TOTAL DECS but only apply for ReportView1 = ‘POTENTIAL_SAVING_VIEW ‘
So the data will be:
NewRecID | RecID | ReportView1 | Name | Value | Total
1 | 3 | CURRENT_VIEW | 'Test1' | 10 | 20
1 | 3 | PROPOSED_VIEW | 'Test33' | 45 | 65
1 | 3 | POTENTIAL_SAVING_VIEW | null | null | 90
2 | 1 | CURRENT_VIEW | 'Test1' | 10 | 20
2 | 1 | PROPOSED_VIEW | 'Test11' | 20 | 30
2 | 1 | POTENTIAL_SAVING_VIEW | null | null | 80
3 | 2 | CURRENT_VIEW | 'Test1' | 10 | 20
3 | 2 | PROPOSED_VIEW | 'Test22' | 25 | 35
3 | 2 | POTENTIAL_SAVING_VIEW | null | null | 70
I could probably use joining withiin itself BUT I am just wondering it may be there is an alternative.
Thanks
(Edited to account for cases with duplicate totals.)
Output: