Results 1 to 3 of 3

Thread: sql statement

  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Unanswered: sql statement

    hi guys...

    i have the following table:

    id value
    =======
    1 100
    2 80
    1 20
    2 50
    ...

    whats the sql statment to generate this:

    id value balance
    ===============
    1 100 100
    1 20 120

    thx in advance...

  2. #2
    Join Date
    Oct 2001
    Location
    Naples, FL
    Posts
    273
    Try this

    select
    a.id,
    a.value,
    sum(b.value) as balance
    from table a, table b
    where b.id <= a.id
    group by a.id, a.value

    HTH
    ---------------
    Ray Higdon MCSE, MCDBA, CCNA

  3. #3
    Join Date
    Sep 2003
    Posts
    2

    Thumbs up


Posting Permissions

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