ich bekomme bei copy&paste Deiner Anweisungen:
[code]
...
insert into ABO values ('A09', 'K04', 'Z01', 'V04');
insert into ABO values ('A10', 'K05', 'Z03', 'V06');
INSERT 0 1
ERROR: value "036211044478" is out of range for type integer
LINE 1: ...a', 'Schmidt', 'Lindenstraße 20', 99867, 'Gotha', '036211044...
^
ERROR: value "03691993446" is out of range for type integer
LINE 1: ...', 'Meyer', 'Hauptstrasse 11', 99817, 'Eisenach', '036919934...
^
ERROR: value "03621552298" is out of range for type integer
LINE 1: ...ig', 'Schulze', 'Linke Gasse 3c', 99867, 'Gotha', '036215522...
^
INSERT 0 1
ERROR: value "03691858328" is out of range for type integer
LINE 1: ...rnd', 'Kluge', 'Hutweide 43a', 99817, 'Eisenach', '036918583...
^
INSERT 0 1
INSERT 0 1
ERROR: value "03691478982" is out of range for type integer
LINE 1: ...iedrich', 'Bruchtaler Weg 12', 99817, 'Eisenach', '036914789...
^
ERROR: value "03619962358" is out of range for type integer
LINE 1: ...', 'Winter', 'Alte Strasse 62c', 99084, 'Erfurt', '036199623...
^
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
ERROR: insert or update on table "abo" violates foreign key constraint "abo_kid_fkey"
DETAIL: Key (kid)=(K02 ) is not present in table "kunden".
ERROR: insert or update on table "abo" violates foreign key constraint "abo_kid_fkey"
DETAIL: Key (kid)=(K03 ) is not present in table "kunden".
INSERT 0 1
INSERT 0 1
INSERT 0 1
ERROR: insert or update on table "abo" violates foreign key constraint "abo_kid_fkey"
DETAIL: Key (kid)=(K04 ) is not present in table "kunden".
ERROR: insert or update on table "abo" violates foreign key constraint "abo_kid_fkey"
DETAIL: Key (kid)=(K04 ) is not present in table "kunden".
ERROR: insert or update on table "abo" violates foreign key constraint "abo_kid_fkey"
DETAIL: Key (kid)=(K04 ) is not present in table "kunden".
INSERT 0 1
[/code]
Du suchst, wenn ich es richtig verstehe, dies:
[code]
postgres=# select kid, sum(z.preis) from abo left join zeitschrift z on abo.zid=z.zid group by kid having sum(z.preis) > 3;
kid | sum
----------------------+-----
K01 | 4.3
K08 | 6.8
(2 rows)
[/code]
Die Wahl Deiner Datentypen ist teilweise grundfalsch: eine PLZ wie auch eine Telefonnummer kann eine führende 0 enthalten, ein INTEGER schneidet diese ab, geb_datum als Text ist auch grundfalsch, wie speicherst Du 4,5% Provision?