Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2005

    Unanswered: Help with SQL Distinct

    Hey all,

    I am querying a student activity table and I want to know the total count for student athletes grouped by sport. The catch is a student can appear in the table more than once. In other words, I want a unique count for each sport.

    I'm using distinct but I'm not sure how to get the count and the description of the sport together. Here's my code:

    select count(distinct sta_key_number), sta_school_activity
    sta_school ='20'
    group by sta_school_activity

    this gives me the count for the duplicates

    556 Cross Country/Track-Mens
    3 ASI Student Government
    1 ASI Cabinet
    1 Athletic Board
    157 Cross Country/Track-Womens
    4 Badminton-Men
    1 Badminton-Women
    466 Baseball
    313 Basketball-Men
    150 Basketball-Women
    28 Cheerleading
    731 Football
    19 Golf
    140 Gymnastics
    225 Soccer-Men
    225 Soccer-Women
    103 Softball
    33 Surfing Club
    200 Swimming-Men
    66 Swimming-Women
    193 Tennis-Men
    77 Tennis-Women
    102 Volleyball
    76 Water Polo
    45 Wrestling
    117 Yacht

    when I do the count without the description, it's more acurate: 3573

    is this possible?

    Thanks for you help!

  2. #2
    Join Date
    Aug 2003
    Where the Surf Meets the Turf @Del Mar, CA
    Provided Answers: 1
    >In other words, I want a unique count for each sport.

    That's nice. I want an income of $1,000,000 per year.

    Please define better "a unique count for each sport."

    If a student participates in more than 1 sport,
    what is the decision criteria for which sport get his/her count?
    You can lead some folks to knowledge, but you can not make them think.
    The average person thinks he's above average!
    For most folks, they don't know, what they don't know.
    Good judgement comes from experience. Experience comes from bad judgement.

Posting Permissions

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