Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 11th, 2003, 01:32 PM
marvel marvel is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 6 marvel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thumbs up Trying to figure out a left outer join - MSSQL 7

I am attempting to use a left outer join but am having a problem joining on the correct records.

Here is my query:
Code:
SELECT    workorders.woDateTime, workorders.woPickedUpDate, machines.machID, machines.machType
FROM         machines LEFT OUTER JOIN
                      workorders ON machines.machID = workorders.woMachID
WHERE     (workorders.woCustID = 993) AND (workorders.woMachID <> 0) AND (workorders.woPickedUpDate IS NULL)
ORDER BY machines.machID


In the database, there are multiple rows in the workorders tables corresponding to each row in the machine table. The machine table has a primary key machID and the workorder table has a foreign key woMachID that corresponds to machID.

What I am trying to do is get the workorder row that has the maximum woDateTime for that machID and also get the value of woPickedUpDate for the row that woDateTime is corresponding to. I can't do an inner join because sometimes it is possible to not have a row in the workorder table for that machID. If this happens then no record would be returned at all.

I seem to be confused on how to do this. If any more explaination is needed please let me know.
Thanks for your time.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Trying to figure out a left outer join - MSSQL 7


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway