Results 1 to 2 of 2
  1. #1
    winterh is offline Competent Performer
    Windows 7 32bit Access 2010 32bit
    Join Date
    Mar 2012
    Posts
    110

    Six Queries and Merg Data

    Hi All



    If I explain what I have and what I want.


    Table1
    Client ID DateSold Product1 Product2 Product3 Product4 Product5 Product6
    1 01/05/12 A A C D D C
    2 01/06/12 C C C D C A
    3 01/06/12 A D D D C A
    4 01/07/12 C A A C B B

    What I want is a query which gives me the below answer andthen I can make a chart.

    DateSold Product(A)
    May 2
    June 1
    July 2
    Total 5

    I have done six queries for each product line eg Query 1shows Product1, second query shows Product2.

    Any help please J

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Need to normalize data. A UNION query will accomplish. There is no wizard or designer for UNION, must type in the SQL View window.

    SELECT [Client ID], DateSold, Month(DateSold) As MonthSold, Year(DateSold) As YearSold, "1" As SourceField, Product1 As ProductCode FROM tablename
    UNION SELECT [Client ID], DateSold, Month(DateSold), Year(DateSold), "2", Product2 FROM tablename
    UNION SELECT [Client ID], DateSold, Month(DateSold), Year(DateSold), "3", Product3 FROM tablename
    UNION SELECT [Client ID], DateSold, Month(DateSold), Year(DateSold), "4", Product4 FROM tablename
    UNION SELECT [Client ID], DateSold, Month(DateSold), Year(DateSold), "5", Product5 FROM tablename
    UNION SELECT [Client ID], DateSold, Month(DateSold), Year(DateSold), "6", Product6 FROM tablename;

    Now use the UNION query as data source for graphing - do aggregate (GROUP BY) query, apply criteria to filter by ProductCode, rotate with crosstab to get ProductCode headings and count data.
    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.

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

Similar Threads

  1. Queries by table data
    By beginner in forum Access
    Replies: 3
    Last Post: 09-11-2014, 06:28 AM
  2. Queries not returning data
    By Verso in forum Queries
    Replies: 1
    Last Post: 08-11-2011, 01:46 AM
  3. Showing data from different queries
    By samefilip in forum Reports
    Replies: 7
    Last Post: 01-06-2011, 11:09 AM
  4. Test data for queries
    By nacho in forum Queries
    Replies: 6
    Last Post: 04-16-2010, 11:01 PM
  5. How to merg fields in MS Access 2003
    By vahidam in forum Queries
    Replies: 0
    Last Post: 02-17-2009, 08:47 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