Skip to content

Instantly share code, notes, and snippets.

@Abuton
Created January 26, 2022 11:03
Show Gist options
  • Save Abuton/75834eb18c8c00bf31c7c2119327cedc to your computer and use it in GitHub Desktop.
Save Abuton/75834eb18c8c00bf31c7c2119327cedc to your computer and use it in GitHub Desktop.
-- write your code in PostgreSQL 9.4
SELECT r.task_id, t.name as task_name,
case when avg(r.score) <= 20 then 'Hard'
when avg(r.score) > 20 and avg(score) <= 60 then 'Medium'
when avg(r.score) > 60 then 'Easy' End As difficulty
from reports r left join tasks t on r.task_id = t.id
group by r.task_id, task_name order by r.task_id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment