Results 1 to 7 of 7
  1. #1
    Adele is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    12

    Comparing sales for the last 2 years

    Hi all,



    I have the following 4 tables:

    Customer
    Invoice details 2010
    Invoice details 2011
    Products (used to specify criteria e.g. search for “plastic” only)

    I need to produce a query that will return sales for each customer for 2010 & 2011, even if the values in 2011 are null and did have a value in 2010 and vice versa.

    Many thanks,

    Adele

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Did you try a join of these tables? Not what you want?

    Invoice details should not be two tables. Use a UNION query to combine these two so you get the effect of one table. Then join this query to the Customer table. There is no wizard or designer for UNION queries, must type into the SQL View window of query designer.

    SELECT * FROM [Invoice Details 2010]
    UNION SELECT * FROM [Invoice Details 2011];

    This assumes the tables have the exact same structure and fields are in the same order.

    Is the invoice number unique across all years?
    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
    Adele is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    12
    thanks for the reply, i have created the union for sales tables 2010 & 2011 and called it ‘unionSales’ I started a new query and used this to pull data from however the query result I get just groups all of the sales from 2010 & 2011 together rather than giving a comparison

    any ideas as to what I am doing wrong?
    many thanks
    Adele

  4. #4
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Perhaps a cross tab query to show the comparisons.

    Look here on how to do that.

    http://www.datapigtechnologies.com/f.../crosstab.html

    Alan

  5. #5
    Adele is offline Novice
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    12
    thanks to both of you,

    i used the union query to link the tables then ran an expression like the guy did in the vid..

    cheers guys!

  6. #6
    cechopin is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    9
    Thank you so much for your question and answers! I have been struggling with this same problem for months! Perfect explanation! So glad I found this!!!

  7. #7
    cechopin is offline Novice
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    9
    Is there a way to subtotal within the query or do I need to do that in the report?

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

Similar Threads

  1. Replies: 5
    Last Post: 06-30-2011, 02:24 AM
  2. Daily Sales Report
    By bayswatergirl in forum Reports
    Replies: 1
    Last Post: 06-02-2011, 12:27 PM
  3. Select changes in the years
    By acs_one in forum Queries
    Replies: 8
    Last Post: 11-27-2010, 05:26 PM
  4. How to Benchmark The Best Month Sales
    By jasonman in forum Queries
    Replies: 4
    Last Post: 11-13-2010, 12:30 PM
  5. Point of Sales Application
    By chico_yallin in forum Access
    Replies: 1
    Last Post: 06-23-2007, 05:30 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