Results 1 to 4 of 4
  1. #1
    smoothlarryhughes is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Sep 2012
    Posts
    36

    Combine records in a table


    Is there a way to query this table back to combine records that have like accounts and like cusips?

    For example records 1 and 2 have the same account and cusip...can i put them in the same line (Account - CUSIP - AMOUNT L - AMOUNT S - DIFFERENCE)? Also PH9217 does not have an offset...i would just have AMOUNT S be 0. L stands for Ledger S for Statement.

    ID account cusip amount L/S
    1 PH4056 123456789 500 L
    2 PH4056 123456789 600 S
    3 PH4055 676767677 1000 L
    4 PH4055 676767677 1000 S
    5 PH9217 123456789 500.01 L

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Will this table have only one L and one S record for each account/CUSIP combination? Is each CUSIP unique to each account?

    1. You need a master data source of all accounts.

    2. Do a query to retrieve all L records

    3. Do a query to retrieve all S records

    4. Join queries 2 and 3 to the master
    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
    smoothlarryhughes is offline Advanced Beginner
    Windows 7 64bit Access 2003
    Join Date
    Sep 2012
    Posts
    36
    Sometimes there might be more than 1 L and 1 S record for each cusip...the same cusip can be in multiple accounts. any chance you could give me an example of your queries using the sample data that I provided?

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,625
    Simple select queries.

    SELECT * FROM table WHERE [L/S] = "L";
    SELECT * FROM table WHERE [L/S] = "S";

    Then try a query that joins each of those to the master. Do you have a table of all account and CUSIP combinations? If not, build one by query of the sample table to return all combinations used in that table.
    SELECT DISTINCT Account, CUSIP FROM table;
    Or do you have a table of accounts and a table of CUSIP's? A query that includes both tables without a join clause will create all possible combinations.

    Now join the first two to the 3rd on the account and CUSIP fields (compound key join). Join type "Include all records from Query3 ..."
    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. Replies: 1
    Last Post: 03-13-2012, 06:11 PM
  2. VBA Loop to Combine Records
    By admessing in forum Queries
    Replies: 23
    Last Post: 03-06-2012, 11:37 AM
  3. Combine master detail records in one query
    By mariost in forum Queries
    Replies: 4
    Last Post: 05-14-2011, 11:25 AM
  4. Replies: 8
    Last Post: 01-21-2011, 10:28 AM
  5. Combine Query Results to One Table
    By pr4t3ek in forum Queries
    Replies: 0
    Last Post: 12-19-2008, 06:37 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