#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    3
    Rep Power
    0
    Hi,

    I have a table with thousands of assessment results in the range 0-66, that I'd like to calculate some statistics for. The format I'd like is:

    Score Frequency
    0 4.5%
    1-3 6.8%
    4-6 4.2%
    . .
    . .
    64-66 0.7%

    Is this possible to do within a single query, or do I need another helping table with the ranges?

    Any help appreciated!
    /Nils
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2000
    Posts
    109
    Rep Power
    15
    Can you give the exact desciption of your table??
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    3
    Rep Power
    0
    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by pwluky:
    Can you give the exact desciption of your table??[/quote]

    It's simple, just an ID and a score column.
  6. #4
  7. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    select score,count(*) from table group by score;

    This will return a result set where each row contains a score and the number of rows where that score is entered.
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    3
    Rep Power
    0
    Yeah, I've tried that, but you see I don't want it by single scores, I want them group by intervals, like all scores between 1 and 3 counted together.

  10. #6
  11. No Profile Picture
    Apprentice Deity
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 1999
    Location
    Niagara Falls (On the wrong side of the gorge)
    Posts
    3,237
    Rep Power
    19
    Then you'll have to manually add the groupings together with a script, which should be quite easy. I can't think of any possible ways to group them together like that with a single query and multiple queries wouldn't be wise from a performance standpoint.

Similar Threads

  1. sql query question...
    By rgb6 in forum MS SQL Development
    Replies: 0
    Last Post: September 8th, 2003, 11:57 AM
  2. join query question. newbie
    By arpia in forum MySQL Help
    Replies: 1
    Last Post: August 31st, 2003, 04:25 AM
  3. query question on an image
    By celtic32 in forum ASP Programming
    Replies: 1
    Last Post: August 25th, 2003, 03:31 PM
  4. sql query question
    By micoucou in forum MySQL Help
    Replies: 2
    Last Post: July 27th, 2003, 04:44 AM
  5. fetch_row question and join query
    By Bun-Bun in forum MySQL Help
    Replies: 7
    Last Post: April 25th, 2003, 03:01 AM

IMN logo majestic logo threadwatch logo seochat tools logo