Results 1 to 2 of 2

Thread: Please Solve:-Row Summation...Multiple Column values to be aggregated

  1. #1
    Join Date
    Aug 2005
    Posts
    2

    Please Solve:-Row Summation...Multiple Column values to be aggregated

    Hello All:

    I am not sure if I wrote the question's title appropriatly or not.....but anyways I wud try to explain the problem.

    I am facing a problem solving the following task in MS Access (I believe it can surely be solved in access or SQL server).I am posting a sample table format here for reference and also postin the expected result table there-after.

    The problem goes like this.(Read Carefully)

    I have a table which contains a payment history with one row per account (each account number is unique) and related payment history for each account.

    Sample Table:

    AcctNo Dt1 P1 Dt2 P2 Dt3 P3 Dt4 P4 .........
    ------------------------------------------------------------------------------------------------------------
    101 | 11/07/2002 | 10.00 | 11/07/2002 | 20.00 | 01/17/2003 | 120.00 | 01/25/2003 | 20.00
    201 | 10/28/2003 | 30.00 | 10/28/2003 | 25.00 | 03/22/2004 | 130.00 | 03/22/2004 | 75.00
    301 | 04/07/2005 | 40.00 | 04/23/2005 | 25.00 | 01/07/2001 | 140.00 | 01/07/2001 | 65.00
    401 | 01/13/1999 | 50.00 | 01/13/1999 | 35.00 | 10/29/2002 | 150.00 | 10/17/2002 | 55.00
    501 | 05/23/2001 | 60.00 | 05/02/2001 | 45.00 | 02/13/2000 | 160.00 | 02/13/2000 | 25.00
    601 | 09/17/1998 | 70.00 | 09/15/1998 | 55.00 | 07/07/1998 | 170.00 | 07/07/1998 | 15.00
    701 | 12/11/2000 | 80.00 | 12/29/2000 | 65.00 | 11/27/1999 | 180.00 | 11/28/1999 | 15.00


    where Dt is date and P1/2/3/... is payment.There cud be 1 or more than 1 payments in a particular month as shown.

    The original file has more than 200 columns for the payment i.e till Dt200,P200


    I need to see aggregated monthly payment history for all accounts. i.e. a table for all accounts with related payments for each month (its OK if a day vary in particular month...consolidation shud be monthly) starting from the earliest to the latest possible.

    Result:-

    Acct Month Pay Month Pay ...........
    ----------------------------------------------------
    101 | 11/2002 | 30.00 | 01/2003 | 140.00 ...........
    201 | 10/2003 | 55.00 | 03/2004 | 205.00 ...........
    301 | 04/2005 | 65.00 | 01/2001 | 205.00 ...........
    401 | 01/1999 | 85.00 | 10/2002 | 205.00 ...........
    501 | 05/2001 |105.00 | 02/2000 | 185.00 ...........
    601 | 09/1998 |125.00 | 07/1998 | 185.00 ...........
    701 | 12/2000 |145.00 | 11/1999 | 195.00 ...........

    I hope I have tried to explain the problem in as much detail as possible.

    Please help me with your valuable solutions to the above task ASAP.If u want i can also send in as attachment the original file i am workin at to ur email id

    Thanks

  2. #2
    Join Date
    Aug 2005
    Posts
    5
    nice question pal
    first thing is that you need to convert into mm/yyyy format which you require which can be done using datepart operator now secondly u need to bring it to a column to perform grouping and not rowwise this can be done using a temp table ie put acc date pay as 3 columns and insert ur contents then grp them and return the contents into the previous structure using a cursor a bit tough but possible

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •