Professional Web Applications Themes

Query best n result - MySQL

Hi! I have a little trouble. I have a set of data. An example: results of a sport competition. I have 8 data for every people and i want the sum of the best 7 results for every people I try everyting, group by..... but i don't know how can i sum for every people his n best result. I'd like a ordered and limited group by statement :-)! Bye bye Alemare...

  1. #1

    Default Query best n result

    Hi! I have a little trouble. I have a set of data.
    An example: results of a sport competition. I have 8 data for every
    people and i want the sum of the best 7 results for every people

    I try everyting, group by..... but i don't know how can i sum for
    every people his n best result.
    I'd like a ordered and limited group by statement :-)!
    Bye bye Alemare

    alemare Guest

  2. #2

    Default Re: Query best n result

    On Mar 29, 5:44 pm, "alemare" <com> wrote: 

    Here's a very basic way. There are other, more generic solutions. Look
    at the examples in the manual.

    SELECT (
    SUM( score ) - MIN(score )
    ) AS total
    FROM mytable GROUP BY id;

    strawberry Guest

  3. #3

    Default Re: Query best n result

    Ok true this is a basic solution but i'd like one more general, maybe
    i've not explain very well my problem :-) i'm not good writing!

    in general m result, take the best n for every people...

    thanks for the answer!

    alemare Guest

Similar Threads

  1. Strange Query Result
    By Mediahouse in forum Coldfusion Database Access
    Replies: 3
    Last Post: January 24th, 11:20 PM
  2. Format query result.
    By Kasper K in forum MySQL
    Replies: 2
    Last Post: June 29th, 02:19 PM
  3. Put query result in cells like
    By briankind in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: May 10th, 04:08 PM
  4. How to deal with big query result?
    By Lin Ma in forum ASP
    Replies: 2
    Last Post: October 10th, 04:16 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139