Chat with a LIVE Microsoft Access Expert!
 
       
 

         

   

Go Back   Access World Forums > Apps and Windows > SQL Server

 
 
Chat with a LIVE Microsoft Access Expert!
Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-15-2007, 11:37 AM
betheball betheball is offline
Registered User
 
Join Date: Feb 2003
Location: West Point, Utah
Posts: 107
betheball
Problem with subquery

The following query works properly:

SELECT DISTINCT UPS_Invoices.TrackingID FROM UPS_Invoices

so does this one:

SELECT DISTINCT AR_19InvoiceHistoryTracking.TrackingID FROM AR_19InvoiceHistoryTracking INNER JOIN ARN_InvHistoryHeader ON ARN_InvHistoryHeader.invoicenumber = AR_19InvoiceHistoryTracking.invoicenumber WHERE ARN_InvHistoryHeader.InvoiceDate <= '"& myDate &"' AND ARN_InvHistoryHeader.InvoiceDate >= '"& myDateLess7 &"'

Each brings back a list of IDs. What I need is a list of all ids in the first recordset that do NOT appear in the second recordset. I would think that could be gotten by this:

SELECT DISTINCT UPS_Invoices.TrackingID FROM UPS_Invoices WHERE UPS_Invoices.TrackingID NOT IN (SELECT DISTINCT AR_19InvoiceHistoryTracking.TrackingID FROM AR_19InvoiceHistoryTracking INNER JOIN ARN_InvHistoryHeader ON ARN_InvHistoryHeader.invoicenumber = AR_19InvoiceHistoryTracking.invoicenumber WHERE ARN_InvHistoryHeader.InvoiceDate <= '"& myDate &"' AND ARN_InvHistoryHeader.InvoiceDate >= '"& myDateLess7 &"')

It does not error, but does not bring back any records when it should.

Thoughts?
Reply With Quote
Sponsored Links
  #2  
Old 05-16-2007, 04:01 AM
SQL_Hell's Avatar
SQL_Hell SQL_Hell is offline
Registered User
 
Join Date: Dec 2003
Location: Maidenhead, Berks, UK
Posts: 1,108
SQL_Hell will become famous soon enough
hi


They are different queries with diferent criteria, so I would assume there is no data that matches the criteria in the second query.
Without knowing your data or your table structures its a bit difficult for anyone apart from you to be able to say why that query returns no records.
Reply With Quote
  #3  
Old 05-21-2007, 07:51 AM
Pauldohert's Avatar
Pauldohert Pauldohert is offline
Something in here
 
Join Date: Apr 2004
Posts: 2,093
Pauldohert is on a distinguished road
try using an outer join all records form the first query and the criteria null in the second
Reply With Quote
Sponsored Links
Reply

Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
conversion problem marc01 General 1 01-01-2007 02:58 AM
Interesting Problem Fenrir General 2 07-21-2004 11:57 AM
Saving Problem mohammadagul Forms 2 04-25-2004 09:01 AM
Problem with Saveing Record mohammadagul Modules & VBA 3 04-25-2004 08:58 AM
Math Problem.. mission2java_78 General 3 08-28-2002 10:24 AM


All times are GMT -8. The time now is 09:44 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
(c) copyright 2009 Access World