mi chiedevo se qualcuno può aiutare con questoquery MySQL con subsort per tipo
ho le seguenti tabelle
user_ids {
uUID
name
}
types {
tUID
name
}
activity {
aUID
user_id
type_id
date
}
modo che gli utenti conterrebbe
uUID name
1 Bob
2 Mark
3 Peter
tipi sarebbe
tUID name
1 Baseball
2 Football
3 Cricket
activit y sarebbe
aUID user_id type_id date
1 1 2
2 1 2
3 1 3
4 2 1
5 2 3
6 2 1
7 3 3
8 3 3
9 3 3
ora quello che vorrei ottenere è la seguente tabella posteriore
Name Type Count of type
Bob Baseball 0
Bob Football 2
Bob Cricket 1
Mark Baseball 2
Mark Football 0
Mark Cricket 1
Peter Baseball 0
Peter Football 0
Peter Cricket 3
posso fare questo con un'unica query di per utente id ma vorrei sapere se c'è un modo per fai questo con una singola query.
Grazie
Martin
Grazie, ha funzionato alla grande. – Martin
l'istruzione with zero non sembra restituire 0 se l'utente non ha eseguito alcuna attività o ha fatto solo 1 EG Peter Cricket 3 ma nient'altro – Martin
No tornerà o utente ha fatto qualche attività o no –