Given a big table of data about when people begin and complete tasks, e.g:
Person | Task | Date started | Date ended --------------------------------------------- A Cleaning 20-FEB-2012 22-FEB-2012 N Dishes 20-FEB-2012 24-FEB-2012 Z Cleaning 21-FEB-2012 23-FEB-2012
and a score table which assigns scores of 2,3,4 for each task based on how long it takes them to do it, e.g.:
| Task | Days taken | Score --------------------------- Cleaning 2 2 Cleaning 1.5 3 Cleaning 1 4 Dishes 3 2 Dishes 2.5 3 Dishes 2 4
how might I produce a query which gives the overall score for each person for each task, e.g.:
Person | Task | Overall Score --------------------------------------------- A Cleaning 3.1 A Dishes 2.7 N Cleaning 3.4
The solution’s been subtly eluding me, some assistance would be appreciated! I’m using SQLite at present.
Your definitions are a bit vague. However, the following should help you:
Handling ranges a bit more difficult. You need to get the two ends of the interval, and then do the join: