Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2003
    Posts
    9

    Exclamation Unanswered: another sql query problem

    I have a table like this

    DESCRIPTION DEBI CREDIT
    -----------------------------------
    Deposit 0.00 100.00
    Withdraw 10.00 0.00
    Payroll 0.00 230.00
    Withdraw 50.00 0.00


    How can i make an query that this table look like this


    ID DESCRIPTION DEBI CREDIT Current Balance
    ---------------------------------------------------------
    1. Deposit 0.00 100.00 100.00
    2. Withdraw 10.00 0.00 90.00
    3. Payroll 0.00 230.00 320.00
    4. Withdraw 50.00 0.00 270.00

    Please help

  2. #2
    Join Date
    Feb 2003
    Location
    Montreal, Canada
    Posts
    117

    Re: another sql query problem

    Try this:

    SELECT TOP 100 PERCENT QTest.ID, QTest.Description, QTest.Debit, QTest.Credit, SUM(QTest.Credit) - SUM(QTest.Debit) AS [Current Balance]
    FROM QTest,
    (SELECT TOP 100 * FROM (SELECT ID, Credit, Debit FROM QTest) QTest_1)
    AS QTest_1
    WHERE QTest.ID >= QTest_1.ID
    GROUP BY QTest.ID, QTest.Description, QTest.Debit, QTest.Credit
    ORDER BY QTest.ID


    where QTest is yout table


    Originally posted by bashka_abdyli
    I have a table like this

    DESCRIPTION DEBI CREDIT
    -----------------------------------
    Deposit 0.00 100.00
    Withdraw 10.00 0.00
    Payroll 0.00 230.00
    Withdraw 50.00 0.00


    How can i make an query that this table look like this


    ID DESCRIPTION DEBI CREDIT Current Balance
    ---------------------------------------------------------
    1. Deposit 0.00 100.00 100.00
    2. Withdraw 10.00 0.00 90.00
    3. Payroll 0.00 230.00 320.00
    4. Withdraw 50.00 0.00 270.00

    Please help
    Steve

Posting Permissions

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