79218727

Date: 2024-11-23 20:08:33
Score: 2
Natty:
Report link

@Charlieface has already shared great options.Here is another one using Case statements only.I have used postgres as an example but let me know which db you are using so if needed syntax can be changed.

Fiddle

SELECT DISTINCT ON (Organization) 
    Organization,
    Year,
    Target
FROM manufacturer_status
WHERE Target IN ('Achieved', 'Partial')
ORDER BY Organization, 
    CASE 
        WHEN Target = 'Achieved' THEN 1
        WHEN Target = 'Partial' THEN 2
    END;

enter image description here

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • User mentioned (1): @Charlieface
  • Low reputation (0.5):
Posted by: samhita