ich eine Zeile für jeden Schüler zu bekommen versuchen, mit folgendem Format:Gruppe und aus verknüpften Tabellen zählen
nsn|last_name|first_name|middle_name|gender|ethnicities|providers|qualifications|vocation_PI|vocation_SI|.....
ein Learner viele Anbieter hat, Anbieter viele Lern bei jedem Provider, hat ein Lernender viele Ergebnisse, gehören Ergebnisse zu einem Lern ein Ergebnis hat ein Standard, ein Standard keine/viele Ergebnisse gehört ein Standard
select l.nsn, l.last_name,l.first_name,l.middle_name, l.gender, GROUP_CONCAT(distinct e.name SEPARATOR '|') as ethnicities, GROUP_CONCAT(distinct p.name SEPARATOR '|') as providers, count(case v.code when 'PI' then 1 else 0 end) as v_PI,count(case v.code when 'SI' then 1 else 0 end) as v_SI,count(case v.code when 'CR' then 1 else 0 end) as v_CR, GROUP_CONCAT(distinct q.name SEPARATOR '|') as qualifications
from learners l
join learner_ethnicity le on l.id = le.learner_id
join ethnicities e on le.ethnicity_id = e.id
join learner_provider lp on l.id = lp.learner_id
join providers p on lp.provider_id = p.id
join results r on lp.id = r.learner_provider_id
join standards s on r.standard_id = s.id
join standard_vocation sv on s.id = sv.standard_id
join vocations v on sv.vocation_id = v.id
join learner_qualification lq on l.id = lq.learner_id
join qualifications q on lq.qualification_id = q.id
group by l.id
viele Berufungen hat ich kann die Anzahl für jede Berufung an die Arbeit; Ich bekomme den gleichen Wert in jedem Zählerfeld (nicht sicher, ob dies eine Summe aller Zählungen ist oder was)
erwartete Ausgabe:
123451234 | Doe | John | James | M | European|Maori | SecondaryProvider|TertiaryProvider | NCEA Level 1|NCEA Level 2|Farming PHD | 185 | 430 | .....
tatsächliche Ausgabe:
123451234 | Doe | John | James | M | European|Maori | SecondaryProvider|TertiaryProvider | NCEA Level 1|NCEA Level 2|Farming PHD | 500 | 500 | .....
Irgendwelche Vorschläge?
count (Fall v.code wenn ‚PI‘ dann 1 sonst 0 Ende), wenn Sie dies überprüfen, wird es geben Wert 1 oder 0 und Ihre die Zählung davon nehmend, wird es der Gesamtanzahl gleich –
Zu einfach! Danke – Wing5wong