Results 1 to 6 of 6
  1. #1
    dougie is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    27

    Cross-quotient query

    I have a table with 10 records, each record with columns A1, A2, A3 etc. A second table also has 10 records with columns B1, B2, B3 etc. I want to write a query that returns 10 records with columns A1/B1, A2/B2, A3/B3 etc. Is this possible without creating temporary tables?
    Last edited by dougie; 01-10-2012 at 05:14 AM.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Do these tables have a common key field? Your first column set has A1, B1, C1 but not the A2 shown in the calcs. Also don't show C1 in any calc. Need complete sample of source data and description of output.
    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
    dougie is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    27

    database attached

    DB with sample tables attached. Typos in my original post corrected, sorry. The common primary key is CellID. The resultant query should have the same number of rows (one for each cell) and 12 columns, each column containing the An/Bn quotient.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Then this is a simple SELECT with one-to-one (INNER) join of the tables and field calculations. This is what queries are for, manipulate data.

    SELECT tblTable1.CellID, [tblTable1].[1]/[tblTable2].[1] AS Calc1
    FROM tblTable2 INNER JOIN tblTable1 ON tblTable2.CellID = tblTable1.CellID;

    I show one calculation, you can build the other 11. This is basic Access functionality and Access Help has guidelines for building queries with calcs if you need more info.
    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.

  5. #5
    dougie is offline Novice
    Windows XP Access 2007
    Join Date
    Dec 2011
    Posts
    27

    Thanks

    Thanks, June 7. My real problems begin when the number of columns (it's actually output from a crosstab, not a table) cannot be predicted. I suspect that temporary tables then become unavoidable --- unless you know different....

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,632
    Nope, if you are dealing with dynamic crosstabs, temp table probably it. Could use VBA code to automate the whole process. Would use a lot of looping structures, recordsets, recordset fields collection. Somewhat advanced programming, above novice level anyway.
    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. How do I use a MODULE in a Cross-Tab Query?
    By timo1999 in forum Modules
    Replies: 2
    Last Post: 12-13-2014, 04:51 PM
  2. Cross Tab Query.
    By cap.zadi in forum Queries
    Replies: 1
    Last Post: 01-04-2012, 01:29 PM
  3. Cross-tab query YTD
    By stremchem in forum Queries
    Replies: 9
    Last Post: 08-26-2010, 10:09 AM
  4. Cross Tab Query
    By RycherX in forum Queries
    Replies: 1
    Last Post: 04-26-2010, 12:19 PM
  5. Cross Tab Query
    By nengster in forum Queries
    Replies: 0
    Last Post: 02-18-2009, 07:12 PM

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