-- An welchen Dienststellen waren die Studenten über alle Hochschulen und Jahrgänge -- Mail Koschek vom 25.09.2013 SELECT y.bez Bezeichnung , w.bezeichnung Vertiefungsbereich , x.vorname , x.nachname , date_format(t1.beginn, '%d.%m.%Y') beginn , date_format(t1.ende, '%d.%m.%Y') ende , t1.abteilung , z.bezeichnung Art , x.hs , y.str , y.plz , y.postfach , y.plz_postfach , y.ort , y.mail FROM stan_antrag t1, stan_vertiefungsbereich w, stud x, stan_dienststellen y, stan_stellenart z WHERE t1.uid=x.uid AND t1.dst_id=y.dst_id AND t1.vert_bereich=w.vbid AND z.artid=t1.art AND t1.status = ( SELECT MAX(t2.status) FROM stan_antrag t2 WHERE t1.aendid = t2.aendid AND t2.status !='2' ) AND (t1.zuweisung is NULL OR t1.zuweisung='Z') union SELECT y.bez Bezeichnung , w.bezeichnung Vertiefungsbereich , x.vorname , x.nachname , date_format(t1.beginn, '%d.%m.%Y') beginn , date_format(t1.ende, '%d.%m.%Y') ende , t1.abteilung , z.bezeichnung Art , x.hs , y.str , y.plz , y.postfach , y.plz_postfach , y.ort , NULL mail FROM stan_antrag t1, stud x, stan_vertiefungsbereich w, stan_dienststellen_tmp y, stan_stellenart z WHERE t1.uid=x.uid AND t1.dst_id=y.dst_id AND t1.vert_bereich=w.vbid AND z.artid=t1.art AND t1.status = ( SELECT MAX(t2.status) FROM stan_antrag t2 WHERE t1.aendid = t2.aendid AND t2.status !='2' ) AND (t1.zuweisung is NULL OR t1.zuweisung='Z') ORDER BY nachname