Professional Web Applications Themes

Pulling statistics on database columns - MySQL

Hi, I've got a database table. A frequent action on this table is collecting some data statistics: Highest and lowest value for certain columns, and the user name they occur at. Currently for 7 different statistics these values are pulled in one query each, by selecting user name and the value we're looking for, SORT value DESC, LIMIT 0,1 I've got a feeling this can be done faster, but I wouldn't know how. I'm using MySQL from PHP. Thanks in advance, -- PleegWat Remove caps to reply...

  1. #1

    Default Pulling statistics on database columns

    Hi,

    I've got a database table. A frequent action on this table is collecting
    some data statistics: Highest and lowest value for certain columns, and
    the user name they occur at.

    Currently for 7 different statistics these values are pulled in one
    query each, by selecting user name and the value we're looking for, SORT
    value DESC, LIMIT 0,1
    I've got a feeling this can be done faster, but I wouldn't know how.

    I'm using MySQL from PHP.

    Thanks in advance,
    --
    PleegWat
    Remove caps to reply
    PleegWat Guest

  2. #2

    Default Re: Pulling statistics on database columns

    PleegWat wrote:
     



    SELECT MAX(whatever),MIN(whatever) FROM table WHERE username = 'joe bloggs';


    --
    Brian Wakem
    Email: http://homepage.ntlworld.com/b.wakem/myemail.png
    Brian Guest

  3. #3

    Default Re: Pulling statistics on database columns

    In article <net>, Brian Wakem says... 
    >
    > SELECT MAX(whatever),MIN(whatever) FROM table WHERE username = 'joe bloggs';[/ref]

    Not quite what I need, actually. I need the username where the max over
    the whole table occurs. Like

    SELECT usename, whatever
    FROM table
    ORDER BY whatever DESC
    LIMIT 0,1

    for 7 values


    --
    PleegWat
    Remove caps to reply
    PleegWat Guest

  4. #4

    Default Re: Pulling statistics on database columns

    PleegWat wrote:
     
    >>
    >> SELECT MAX(whatever),MIN(whatever) FROM table WHERE username = 'joe
    >> bloggs';[/ref]
    >
    > Not quite what I need, actually. I need the username where the max over
    > the whole table occurs. Like
    >
    > SELECT usename, whatever
    > FROM table
    > ORDER BY whatever DESC
    > LIMIT 0,1
    >
    > for 7 values[/ref]


    If sub-selects are available:-

    SELECT username,whatever FROM table WHERE whatever = (SELECT MAX(whatever)
    FROM table);


    --
    Brian Wakem
    Email: http://homepage.ntlworld.com/b.wakem/myemail.png
    Brian Guest

Similar Threads

  1. Pulling from Database
    By groh in forum Dreamweaver AppDev
    Replies: 1
    Last Post: May 4th, 04:36 AM
  2. Pulling BLOBs from Database
    By jl_forum in forum Coldfusion Database Access
    Replies: 1
    Last Post: March 30th, 08:05 AM
  3. Javascript pulling from ColdFusion Database
    By djob66 in forum Macromedia ColdFusion
    Replies: 0
    Last Post: March 14th, 08:10 PM
  4. Pulling part of test out of a field in a database?
    By lazerbrains555 in forum Macromedia ColdFusion
    Replies: 6
    Last Post: March 11th, 07:42 PM
  5. Pulling images out of a database
    By Murray *TMM* in forum Macromedia Dreamweaver
    Replies: 3
    Last Post: July 9th, 08:34 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