i have 5 years spend data for 3 products like below , same can find in live sql also .
Oracle Live SQL - Script: Session 01 (0 Bytes)
REPORT_ID ENTITY_ID TMC FY
458 9106166 7522 2025
458 9106166 7303 2024
458 9106166 7125 2023
458 9106166 6951 2022
458 9106166 6951 2021
458 8764180 6813 2025
458 8764180 6573 2024
458 8764180 6386 2023
458 8764180 5910 2022
458 8764180 5684 2021
458 0594502 7257 2025
458 0594502 7041 2024
458 0594502 6832 2023
458 0594502 6800 2022
458 0594502 6769 2021
can you please help me to get below result using ORDER by clause .
- first pick 2021 data , find max tmc
2)based on 2021 tmc ,remaining years( entity_id ) data should follow.
Output should be like below
REPORT_ID ENTITY_ID TMC FY
458 9106166 6951 2021
458 9106166 6951 2022
458 9106166 7125 2023
458 9106166 7303 2024
458 9106166 7522 2025
458 0594502 6769 2021
458 0594502 6800 2022
458 0594502 6832 2023
458 0594502 7041 2024
458 0594502 7257 2025
458 8764180 5684 2021
458 8764180 5910 2022
458 8764180 6386 2023
458 8764180 6573 2024
458 8764180 6813 2025