#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Return The Sum Of The Same ID


    hey guys I need a little help my problem is this:

    points_ledger table

    ledger_id | date | running_balance | fkmember |
    1 | 01/29/12 | 5 | 1 |
    2 | 02/16/12 | 30 | 1 |
    3 | 02/30/12 | 500 | 2 |

    Thats my simple table: Now My Problem is. How can i get the sum of the running_balance of the same fkmember? And my output should be like this when i want to display in PHP.

    fkmember | running_balance |
    1 | 35 |
    2 | 500 |

    Please help me guys im in a middle of a project.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2008
    Posts
    1,928
    Rep Power
    378
    Have you managed to find any examples of queries that involve some kind of SUM?
  4. #3
  5. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,280
    Rep Power
    4279
    i wish my bank would give me the "sum of the running balance" in my account every month
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    Yes I Saw Many Examples But None Of It Works. I think Ill Have To Use Inner Join But I Dont Know How To Do It
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Mar 2008
    Posts
    1,928
    Rep Power
    378
    You need a SUM and a GROUP BY, and nothing else!
  10. #6
  11. Hockey face
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    St. Catharines, Canada
    Posts
    8,147
    Rep Power
    1317
    Originally Posted by rochellecanale
    Yes I Saw Many Examples But None Of It Works. I think Ill Have To Use Inner Join But I Dont Know How To Do It
    Two things to point out.

    a) you are a new member to the forum
    b) the question looks like homework

    When regular users see that they expect the poster is trying to get them to do the work for them.

    If you are looking for assistance then you need to show that you've done some work. People will be happy to assist when they see you've put in the effort.

IMN logo majestic logo threadwatch logo seochat tools logo