Results 1 to 3 of 3
  1. #1
    kkt is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    2

    Access query

    Hi, need some help. what is the Access query to get the desired result for below scenario ? Thank you...



    Conditions to delete rows:
    Remove 0 spend for company repeated more than once.
    Do not remove valid company with 0 spend.
    Do not aggregate the spend

    Company Spend ($)
    A 1,000
    A 2,000
    A remove
    B 3,000
    B remove
    C 3,000
    C 2,000
    C remove
    D do not remove. valid company 0 spend
    E remove
    E 8,000
    F do not remove. valid company 0 spend

    Desired Result
    Company Spend ($)
    A 1,000
    A 2,000
    B 3,000
    C 3,000
    C 2,000
    D
    E 8,000
    F

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This will require a Totals query to get count of records for each company. Here is nested query.

    DELETE FROM Table1 WHERE Spend Is Null And Company In(SELECT Table1.Company
    FROM (SELECT Company, Count(Company) AS CountOfCompany
    FROM Table1 GROUP BY Company) As CompanyCount INNER JOIN Table1 ON CompanyCount.Company = Table1.Company
    WHERE CountOfCompany>1 AND Spend Is Null);
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    kkt is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Posts
    2

    Access query

    It works!! Thanks !!

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

Similar Threads

  1. Access query HELP!
    By rlh1963 in forum Access
    Replies: 7
    Last Post: 10-05-2011, 09:58 AM
  2. Replies: 12
    Last Post: 05-22-2011, 03:49 PM
  3. Convert Access query to SQL Server query
    By mkallover in forum Queries
    Replies: 2
    Last Post: 05-13-2011, 06:20 AM
  4. Replies: 10
    Last Post: 02-02-2011, 05:48 PM
  5. Sql server query to MS access query
    By blazixinfo@yahoo.com in forum Queries
    Replies: 0
    Last Post: 07-07-2009, 08:12 AM

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