I'm searching for a specific SQL Query to automatically set "Priority" cell value if the value of the "Days Left" is :
- 7 days or less = High
- 14 days or less = Medium
- 30 days or less = Low
- 31 days or more = Very Low
this is my table looks like
Tasks | Due Date | Days Left |
---------+----------------+------------+
AAAAA | 20/12/2019 | 3 |
BBBBB | 25/12/2019 | 8 |
CCCCC | 01/01/2020 | 15 |
DDDDD | 17/01/2020 | 31 |
result i want
Tasks | Due Date | Days Left | Priority |
---------+----------------+------------+------------+
AAAAA | 20/12/2019 | 3 | High |
BBBBB | 25/12/2019 | 8 | Medium |
CCCCC | 01/01/2020 | 15 | Low |
DDDDD | 17/01/2020 | 31 | Very Low |
current mysql query
SELECT
tasks,
due_date,
DATEDIFF(due_date, CURDATE()) AS days_left,
____________________________________ AS priority
case when ... thenw3schools