X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 115AC3A57CB for ; Tue, 25 Jan 2005 17:06:17 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 88388-03 for ; Tue, 25 Jan 2005 17:06:07 +0000 (GMT) Received: from rproxy.gmail.com (rproxy.gmail.com [64.233.170.202]) by svr1.postgresql.org (Postfix) with ESMTP id CA09C3A57B6 for ; Tue, 25 Jan 2005 17:06:05 +0000 (GMT) Received: by rproxy.gmail.com with SMTP id f1so154877rne for ; Tue, 25 Jan 2005 09:06:05 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:mime-version:content-type:content-transfer-encoding; b=M9y2FR1sx50XNESo+rGc+G1koYOK4hDRWdIEk8XKnbTe5SOeY3pboasXZpJrXNTiLCP3Y5gIIduLA1fpCWqfYSUAqqGfeu935lHfsVZcbCB/OP2NEAuxltp5Gx/qfj6FRZhpVZkCj8OmELZ6cQrOakWHJMRqLjbxU4ojBVb55c8= Received: by 10.38.12.60 with SMTP id 60mr116947rnl; Tue, 25 Jan 2005 09:06:04 -0800 (PST) Received: by 10.38.81.69 with HTTP; Tue, 25 Jan 2005 09:06:04 -0800 (PST) Message-ID: Date: Tue, 25 Jan 2005 18:06:04 +0100 From: Thomas Chille Reply-To: thomas@chille.de To: "pgsql-sql@postgresql.org" Subject: difficult JOIN Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.259 tagged_above=0 required=5 tests=AWL, RCVD_BY_IP, TO_ADDRESS_EQ_REAL X-Spam-Level: X-Archive-Number: 200501/216 X-Sequence-Number: 20004 Hi, i have the following SQL-Problem: We are using 2 tables. The first, called plan, is holding planned working times for employees per tour: plan.id_tour plan.id_employee plan.begin_time plan.end_time The second table 'work' stores the actual worked times for employees per tour: work.id_tour work.id_employee work.begin_time work.end_time Employees can be multiple times assigned to one tour. One record will be created for every assignment. They can also work multiple times in one tour. Now i wanna merge this infos into one report. I wanna join the first plan entry for one employee in one tour with the first work entry for one employee in one tour and so on. How can i obtain that? A simply USING(id_tour, id_employee) -JOIN will not doit. Thanks for any hints, Thomas