Results 1 to 2 of 2
  1. #1
    jgalich is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jul 2015
    Posts
    1

    Show Sale and No-Sale Accounts

    Hi.

    First time post here.

    I use Access 2007 and am trying to generate what I think is a relatively simple query to show all accounts, whether they have sales history or not. Customer information is housed in a table called TBLCUSTOMERS; sales data is housed in a table called Net_Sales_2010-Present; and there is a third table call Territory_Attributes that we use to determine sales region.

    I built the query as shown in the screen grab below, using an outer join on Account_Number with "Customers" and "Net Sales" thinking this will give me No Sale and Sold accounts. Still, I am only getting sold accounts:

    Click image for larger version. 

Name:	Access_Query.jpg 
Views:	7 
Size:	133.4 KB 
ID:	21216



    Here's the SQL:

    SELECT Territory_Attributes.Sub_Region, MARKETING_REPORTS_TBLCUSTOMERS.REP_NUMBER, MARKETING_REPORTS_TBLCUSTOMERS.ACCOUNT_NUMBER, MARKETING_REPORTS_TBLCUSTOMERS.BCUST_NAME, "20" & Left([pdate],2) AS [Year], Sum([Net_Sales_2010-Present].BILLED_AMOUNT) AS SumOfBILLED_AMOUNT
    FROM (MARKETING_REPORTS_TBLCUSTOMERS INNER JOIN Territory_Attributes ON MARKETING_REPORTS_TBLCUSTOMERS.REP_NUMBER = Territory_Attributes.ter) LEFT JOIN [Net_Sales_2010-Present] ON MARKETING_REPORTS_TBLCUSTOMERS.ACCOUNT_NUMBER = [Net_Sales_2010-Present].ACCT
    WHERE ((([Net_Sales_2010-Present].PDATE)<150701))
    GROUP BY Territory_Attributes.Sub_Region, MARKETING_REPORTS_TBLCUSTOMERS.REP_NUMBER, MARKETING_REPORTS_TBLCUSTOMERS.ACCOUNT_NUMBER, MARKETING_REPORTS_TBLCUSTOMERS.BCUST_NAME, "20" & Left([pdate],2)
    HAVING (((Territory_Attributes.Sub_Region)="NA North"));

    Just to see, I tried the other two join variations to no avail. Is what I want not possible, or am I doing something wrong?

    Thanks for the assistance!



    John Galich



    Just to see, I tried the other two join variations to no avail. Is what I want not possible, or am I doing something wrong?

    Thanks for the assistance!

    John Galich

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You could do it in 2 querys and put them together in a single UNION query.
    the one above gives you SOLD,
    then make another with no sales.
    Put them together as :

    select * from qsSold
    union
    select * from qsNoSale

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

Similar Threads

  1. point of sale tutorial
    By Ternick in forum Access
    Replies: 8
    Last Post: 02-03-2015, 09:37 PM
  2. Days since last sale
    By bandmolson in forum Queries
    Replies: 1
    Last Post: 03-17-2014, 01:01 PM
  3. Criteria for a monthly sale
    By xtrareal22 in forum Queries
    Replies: 2
    Last Post: 12-18-2013, 10:14 AM
  4. Sale Silver Jewelry
    By azhar2006 in forum Database Design
    Replies: 2
    Last Post: 12-01-2013, 09:00 AM
  5. Group results to show last sale
    By tweety in forum Queries
    Replies: 21
    Last Post: 04-30-2013, 08:48 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