Results 1 to 3 of 3
  1. #1
    aaslezak is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    34

    Question SQL statement with double negative

    I need to write the Where clause on an SQL statement so they both have to be true and records are not included otherwise I want the records included. Here is the statement:


    SELECT [AMA IT Count Developer Estimate Table].[Project #], Personnel.[Project ID], Personnel.[Person ID], Personnel.Name, Personnel.Title, Personnel.Assigned, Personnel.Complete, Personnel.[Actual Hours], Personnel.[Estimated Hours], Personnel.[MO Issues], Personnel.[Prod Issues], Personnel.[Remaining Hours], [AMA IT Count Developer Estimate Table].CountOfTitle INTO [AMA IT Personnel 1]
    FROM [AMA IT Count Developer Estimate Table] INNER JOIN Personnel ON [AMA IT Count Developer Estimate Table].[Project ID] = Personnel.[Project ID]
    WHERE ((Personnel.Title) Not Like "Estimate*" AND ([AMA IT Count Developer Estimate Table].CountOfTitle)<2);

    So if either of these are false like the Personnel.Title is Estimate and the CountOfTitle is 1 then I want it included. If the Personnel.Title is not Estimate and the CountOfTitle is 2 I want it included in the query. So how do I write the statement.

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Your logic is a bit confusing and seems to possibly contradict itself in certain places. I cannot be certain what you actually want.

    Can you restate your question this way:
    I want to include the record if:
    Condition 1 is met
    AND/OR
    Condition 2 is met.

    So, what I am looking for is what Condition 1 is, what Condition 2 is, and is it an AND or an OR thing.
    Nothing else. Let's keep it that simple.

  3. #3
    aaslezak is offline Advanced Beginner
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2015
    Posts
    34
    It's okay I figured it out I just needed an or statement.

    SELECT [AMA IT Count Developer Estimate Table].[Project #], Personnel.[Project ID], Personnel.[Person ID], Personnel.Name, Personnel.Title, Personnel.Assigned, Personnel.Complete, Personnel.[Actual Hours], Personnel.[Estimated Hours], Personnel.[MO Issues], Personnel.[Prod Issues], Personnel.[Remaining Hours], [AMA IT Count Developer Estimate Table].CountOfTitle INTO [AMA IT Personnel 1]
    FROM Personnel LEFT JOIN [AMA IT Count Developer Estimate Table] ON Personnel.[Project ID] = [AMA IT Count Developer Estimate Table].[Project ID]
    WHERE (((Personnel.Title) Not Like "Estimate*") AND (([AMA IT Count Developer Estimate Table].CountOfTitle)>0)) OR (((Personnel.Title) Like "Estimate*") AND (([AMA IT Count Developer Estimate Table].CountOfTitle)=1));

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Using the (000.00) for a negative number
    By keiath in forum Forms
    Replies: 4
    Last Post: 01-10-2015, 04:43 PM
  2. Replies: 7
    Last Post: 06-29-2013, 06:01 PM
  3. Positive to Negative
    By greek-autumn in forum Queries
    Replies: 3
    Last Post: 03-24-2013, 05:20 PM
  4. Single and double quotes in a INSERT statement
    By dccjr in forum Programming
    Replies: 16
    Last Post: 03-14-2013, 09:50 PM
  5. OpenReport Command with Double Check Where Statement
    By Robert M in forum Programming
    Replies: 3
    Last Post: 09-17-2009, 04:01 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums