Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2002
    Location
    Kyiv, Ukraine
    Posts
    77

    Unanswered: SUM() issues? ...

    Have a table:

    ----------------
    Results:
    ----------------
    "id"
    "tour_id"
    "user_id"
    "points"
    ----------------

    Need to get the the following recordset after quering:
    -----------------
    "user_id"
    "rating" (which is equal to SUM of 3 maximum elements from "points" field in Results table ...)
    -----------------

    The problem is that when you just use SUM you will get sum of *all* values in points field for current user and I need to get only sum of 3 maximum elements for current user ...

    Any idea how this could be done?

    TIA.
    Yours faithfully,
    Yaroslav Zaremba

  2. #2
    Join Date
    Feb 2003
    Posts
    17

    Re: SUM() issues? ...

    Originally posted by aZa
    Have a table:

    ----------------
    Results:
    ----------------
    "id"
    "tour_id"
    "user_id"
    "points"
    ----------------

    Need to get the the following recordset after quering:
    -----------------
    "user_id"
    "rating" (which is equal to SUM of 3 maximum elements from "points" field in Results table ...)
    -----------------

    The problem is that when you just use SUM you will get sum of *all* values in points field for current user and I need to get only sum of 3 maximum elements for current user ...

    Any idea how this could be done?

    TIA.
    You can specifiy WHERE field = whatever in the SUM() query to limit specific values to the sum.
    Last edited by progress; 02-06-03 at 16:54.

  3. #3
    Join Date
    Sep 2002
    Location
    Kyiv, Ukraine
    Posts
    77
    Yes, I know this. The problem is on getting such expression in WHERE condition which will retrieve only 3 maximum elements in points field for every user ...
    Yours faithfully,
    Yaroslav Zaremba

Posting Permissions

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