MySQL Forums
Forum List  »  German

Subselect filtern
Posted by: J?rg B?chner
Date: July 03, 2012 04:49AM

Hallo,

ich habe eine Tabelle mit Einkaufsnrn. und den Nummern der Lagerorte, wo diese
Einkäufe komplett oder in Teilen eingelagert sind.
CREATE TABLE t (ek INT, lager INT);
INSERT INTO TABLE t VALUES (1,10);
INSERT INTO TABLE t VALUES (1,10);
INSERT INTO TABLE t VALUES (1,10);
INSERT INTO TABLE t VALUES (1,12);
INSERT INTO TABLE t VALUES (1,11);
INSERT INTO TABLE t VALUES (2,20);
INSERT INTO TABLE t VALUES (2,21);
INSERT INTO TABLE t VALUES (2,21);
INSERT INTO TABLE t VALUES (3,10);
INSERT INTO TABLE t VALUES (4,40);
INSERT INTO TABLE t VALUES (5,11);
INSERT INTO TABLE t VALUES (5,11);

Nun hätte ich gerne alle diejenigen Einkäufe (mit den dazugehörenden Lagernummern) angezeigt,
die in mehr als einem Lager liegen.
+------+-------+
| ek   | lager |
+------+-------+
|    1 |    10 |
|    1 |    11 |
|    1 |    12 |
|    2 |    20 |
|    2 |    21 |
+------+-------+
Aus einem Subselect
SELECT * FROM t GROUP BY ek, lager
müssten also noch alle Tupel rausgefiltert werden mit einer Ek-Nr., die nur einmal erscheint.
Aber wie?

Options: ReplyQuote


Subject
Views
Written By
Posted
Subselect filtern
1638
July 03, 2012 04:49AM
883
July 04, 2012 05:20AM
858
July 04, 2012 09:44AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.