Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338

    Combine data from one table

    Hello-

    Need a little help with queries. I have two tables, one holds all of patient demo and the second has charges, payments and adjustments.

    This is how the data looks on the second table


    BillingProviderLastName PtAcct SvcDateStamp FinTransDateStamp Charges Payments Adjustments PtProcCodeCPT TransType TransDesc
    John 3585 9/5/2013 9/9/2013 $150.00 20610 Charges Charges
    John 3585 9/5/2013 9/9/2013 $100.00 99214 Charges Charges
    John 3585 9/5/2013 9/9/2013 $25.00 J1030 Charges Charges
    John 3585 9/5/2013 10/21/2013 $50.00 20610 Adjustments Adjustment - Contractual
    John 3585 9/5/2013 10/21/2013 $100.00 20610 Payments Ins Pay Lockbox
    John 3585 9/5/2013 10/21/2013 $50.00 99214 Adjustments Adjustment - Contractual
    John 3585 9/5/2013 10/21/2013 $50.00 99214 Payments Ins Pay Lockbox
    John 3585 9/5/2013 10/21/2013 $20.00 J1030 Payments Ins Pay Lockbox
    John 3585 9/5/2013 6/16/2014 $5.00 20610 Adjustments ADJ - OFFDISC
    $275.00 $170.00 $105.00



    I Would like the data to look like this
    BillingProviderLastName PtAcct SvcDateStamp PtProcCodeCPT Charges Payments Adjustments
    John 3585 9/5/2013 20610 $150.00 $100.00 $50.00
    John 3585 9/5/2013 99214 $100.00 $50.00 $50.00
    John 3585 9/5/2013 J1030 $25.00 $20.00 $5.00
    $275.00 $170.00 $105.00



  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Options:

    1. build a report and use grouping & sorting features with aggregate calcs in footers

    2. build two queries
    query 1 would be an aggregate (GROUP BY) totals query for the accounting data
    query 2 would join query 1 to the patient demo table
    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
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    Thank you June7
    It worked out great

    I have another questions. In the query i add a field(Balance). It's subtracting charges,paments and adjustments.
    The results are coming out correct. I would like to remove zero balance but keep any credits.

    PtProcCodeCPT SumOfCharges SumOfPayments SumOfAdjustments Balance
    99214 $150.00 $125.00 $50.00 ($25.00)
    J1040 $15.00 $5.00 $5.00 $5.00

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Do you mean exclude PtProcCodeCPT records where the balance is 0? Apply filter criteria to the Balance field: <>0
    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
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    Yes June that's what i mean.
    I try putting <>0 but it didn't work.

    Thank you

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Filter criteria on an aggregate calc works for me.

    Post the SQL statement or provide db for analysis. Follow instructions at bottom of my post.
    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.

  7. #7
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    i was going to provide you with a db but after setting it up it works on that db.
    Not sure why it’s not working on the original one.

    Here is the SQL
    SELECT Query1.BillingProviderLastName, Query1.PtAcct, Query1.SvcDateStamp, Query1.SumOfCharges, Query1.SumOfPayments, Query1.SumOfAdjustments, [SumOfCharges]-[SumOfPayments]-[SumOfAdjustments] AS Balance
    FROM Query1
    GROUP BY Query1.BillingProviderLastName, Query1.PtAcct, Query1.SvcDateStamp, Query1.SumOfCharges, Query1.SumOfPayments, Query1.SumOfAdjustments, [SumOfCharges]-[SumOfPayments]-[SumOfAdjustments]
    HAVING ((([SumOfCharges]-[SumOfPayments]-[SumOfAdjustments])<>0));

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Why are you grouping in this query? The grouping was already done in Query1.

    SELECT Query1.BillingProviderLastName, Query1.PtAcct, Query1.SvcDateStamp, Query1.SumOfCharges, Query1.SumOfPayments, Query1.SumOfAdjustments, [SumOfCharges]-[SumOfPayments]-[SumOfAdjustments] AS Balance
    FROM Query1
    WHERE Balance<>0;
    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.

  9. #9
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    Not sure why i put grouping on that query.
    Try using your sql and i'm getting this error
    Enter Parameter value Balance

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Open the query in Design view. Under the Balance calculated field on the criteria row type <>0. Then switch to SQL view to see the syntax. What does it look like?
    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.

  11. #11
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    SELECT Query1.BillingProviderLastName, Query1.PtAcct, Query1.SvcDateStamp, Query1.PtProcCodeCPT, Query1.SumOfCharges, Query1.SumOfPayments, Query1.SumOfAdjustments, [SumOfCharges]-[SumOfPayments]-[SumOfAdjustments] AS Balance
    FROM Query1
    WHERE ((([SumOfCharges]-[SumOfPayments]-[SumOfAdjustments])<>0));

  12. #12
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    i think i found the problem
    Under balance calculation in datasheet view, some of the numbers are coming out like this 2.8421709430404E-14

  13. #13
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    So that is a negative value to 14 decimals? Access can do some weird stuff with calculations. Perhaps you should use Round() function on the calc.
    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.

  14. #14
    Ray67 is offline Competent Performer
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    338
    Not sure what you mean
    Did you want me to use Round() on this field Balance: [SumOfCharges]-[SumOfPayments]-[SumOfAdjustments]

  15. #15
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Yes, can't hurt to see what happens.
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combine Similar Data From Three Queries
    By Kerberos in forum Reports
    Replies: 2
    Last Post: 05-02-2014, 11:27 AM
  2. Combine records in a table
    By smoothlarryhughes in forum Queries
    Replies: 3
    Last Post: 09-14-2012, 08:14 PM
  3. Combine data
    By DSM1957 in forum Queries
    Replies: 1
    Last Post: 07-16-2012, 04:51 AM
  4. Combine duplicated data in a report
    By padfoot in forum Reports
    Replies: 3
    Last Post: 03-24-2012, 08:41 AM
  5. Combine data from 3 different tables
    By udigold1 in forum Queries
    Replies: 3
    Last Post: 06-29-2011, 12:18 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