Loesung zur Aufgabe 1 auf Blatt 04 - SEP SS 2008 ================================================ 1.) SELECT * FROM Termine T where mitarbeiterID = 7 and datum like "2005-01%"; 2.) SELECT max(entfernung) FROM EntfernungFilialen E; 3.) mysql> select plz from Filialen F where id = (SELECT filialID FROM EntfernungFilialen E1 where entfernung = (select max(entfernung) from EntfernungFilialen E2)); 4.) select * from Termine where mitarbeiterID>(select max(id) from Mitarbeiter M); besser noch: select * from Termine where mitarbeiterID not in (select id from Mitarbeiter M); 5.) SELECT * FROM Filialen F where plz >=89100 and plz <=89300; 6.) select strasse, entfernung from Filialen F, EntfernungFilialen E where F.ort like "Ulm%" and F.id=E.filialID; 7.) SELECT name, datum, zeit FROM Termine T, Mitarbeiter M where T.filialID = "lehr" and T.datum >="2006-01-01" and T.datum <="2006-06-30" and T.mitarbeiterID=M.id and M.stufe>1 and M.geschlecht ="w"; 8.) select filialID, sum(betrag) from Abrechnungen where datum like "2007%" group by filialID; 9.) elect F.id, F.strasse, F.plz, F.ort, sum(betrag) from Filialen F, Abrechnungen A where A.datum like "2006%" and F.id = A.filialID group by A.filialID having sum(betrag) > 35000; 10.) select distinct(M.name), M.id from Mitarbeiter M, Termine T1, Termine T2 where M.id = T2.mitarbeiterID and T1.datum > "2008-03%" and T1.mitarbeiterID=3 and T1.filialID=T2.filialID and T2.datum > "2008-03%" and T2.mitarbeiterID != T1.mitarbeiterID order by M.id;