If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ANSI SQL > Query involving join

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-01-04, 05:45
mozartz mozartz is offline
Registered User
 
Join Date: Apr 2004
Posts: 12
Question Query involving join

I am having some problems with a query.

I have two tables ‘WORK’ and ‘WORKHIST’


WORK’
----------

JOB WORKER STATUS
1222 AB A
1223 AB B
1224 CD B
1225 AB B
1226 CD A

WORKHIST
----------------
JOB WORKER DESC
1222 AB NULL
1222 AB NULL
1222 AB SOME TEXT
1224 CD NULL
1224 CD NULL
1225 AB NULL
1225 AB NULL

I wish to find all JOBS where STATU=’A’ and DESC IS NULL

Problem is I can’t get a query where I don’t get multiple rows as I do the join on
WORK.WORKER=WORHIST.WORKER

I want a single unique row for each JOB wjocj meets the described condition.

Help appreciated
Reply With Quote
  #2 (permalink)  
Old 04-01-04, 06:57
zeus77 zeus77 is offline
Registered User
 
Join Date: Mar 2004
Location: Venice,Italy
Posts: 20
if you want find out every job with almost a worker with status "A" and without any desc you can try this:

select
WORK.JOB
from work,WORKHIST
where WORK.JOB=WORHIST.JOB
group by WORK.JOB
having
max(WORKHIST.DESC) is null and
min(WORK.STATUS)='A';

Please note that I used the fact that 'A'<'B'...

Last edited by zeus77; 04-01-04 at 06:59.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On