I need help with creating a query.
I have a table that ranks people by week.
PessoaId | Semana | Grupo ---------------------------- 1 | 1 | 1 1 | 2 | 1 1 | 3 | 1 1 | 4 | 1 2 | 1 | 1 2 | 2 | 2 2 | 3 | 2 2 | 4 | 1 3 | 1 | 2 3 | 2 | 2 3 | 3 | 2 3 | 4 | 2
I need a query to count how many weeks they have been out of group 1 and / or how many weeks ago they are out of group 1. This week a week. Result wanted more or less
PessoaId | Semana | Tempo Fora ---------------------------------- 1 | 1 | 0 1 | 2 | 0 1 | 3 | 0 1 | 4 | 0 2 | 1 | 0 2 | 2 | 1 2 | 3 | 2 2 | 4 | 0 3 | 1 | 1 3 | 2 | 2 3 | 3 | 3 3 | 4 | 4