create table t
(
name char(3),
part char(3)
);
insert into t
(name, part)
values
("aaa", "pt1");
insert into t
(name, part)
values("aaa", "pt2");
insert into t
(name, part)
values("aaa", "pt3");
insert into t
(name, part)
values("bbb", "pb1");
insert into t
(name, part)
values("bbb", "pt3");
insert into t
(name, part)
values
("ccc", "pt2");
select a.name, a.part, b.part from t as a inner join t as b on a.name = b.name where a.part < b.part;
Y3JlYXRlIHRhYmxlIHQKKApuYW1lIGNoYXIoMyksCnBhcnQgY2hhcigzKQopOwoKCmluc2VydCBpbnRvIHQKKG5hbWUsIHBhcnQpCnZhbHVlcwooImFhYSIsICJwdDEiKTsKaW5zZXJ0IGludG8gdAoobmFtZSwgcGFydCkKdmFsdWVzKCJhYWEiLCAicHQyIik7Cmluc2VydCBpbnRvIHQKKG5hbWUsIHBhcnQpCnZhbHVlcygiYWFhIiwgInB0MyIpOwppbnNlcnQgaW50byB0CihuYW1lLCBwYXJ0KQp2YWx1ZXMoImJiYiIsICJwYjEiKTsKaW5zZXJ0IGludG8gdAoobmFtZSwgcGFydCkKdmFsdWVzKCJiYmIiLCAicHQzIik7Cmluc2VydCBpbnRvIHQKKG5hbWUsIHBhcnQpCnZhbHVlcwooImNjYyIsICJwdDIiKTsKCnNlbGVjdCBhLm5hbWUsIGEucGFydCwgYi5wYXJ0IGZyb20gdCBhcyBhIGlubmVyIGpvaW4gdCBhcyBiIG9uIGEubmFtZSA9IGIubmFtZSB3aGVyZSBhLnBhcnQgPCBiLnBhcnQ7Cg==