SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: count() based on current row - multiple rows

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2010
    Posts
    50
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    count() based on current row - multiple rows

    with oracle i am trying to count the amount a user spent on items in total. but printing out all the users.

    username id totalspent
    james 3 10
    clair 4 15

    how would i count the amount spent where the user id is different every time.

    Thanks guys!

  2. #2
    SQL Consultant silver trophybronze trophy
    SitePoint Award Recipient r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    38,457
    Mentioned
    34 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by wazzaday View Post
    how would i count the amount spent where the user id is different every time.
    Code:
    SELECT userid
         , SUM(totalspent)
      FROM daTable
    GROUP BY userid
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

Bookmarks

Posting Permissions

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