Unix Technical Forum

difficult JOIN

This is a discussion on difficult JOIN within the Pgsql General forums, part of the PostgreSQL category; --> Hi, i have the following SQL-Problem: We are using 2 tables. The first, called plan, is holding planned working ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > Pgsql General

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 07:08 PM
Thomas Chille
 
Posts: n/a
Default difficult JOIN

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


---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 07:09 PM
Sim Zacks
 
Posts: n/a
Default Re: difficult JOIN

You're going to need a cursor or a for loop. No way to join them.


""Thomas Chille (spoon)"" <t.chille@spoon.de> wrote in message
news:006101c502f9$342920b0$500a0a0a@spoon.de...
> 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
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 8: explain analyze is your friend
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:06 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com