Thread: Help with SQL Distinct
10-03-05, 20:45 #1Registered User
- Join Date
- Oct 2005
Unanswered: Help with SQL Distinct
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
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
33 Surfing Club
76 Water Polo
when I do the count without the description, it's more acurate: 3573
is this possible?
Thanks for you help!
10-03-05, 21:43 #2Registered User
Provided Answers: 1
- Join Date
- Aug 2003
- Where the Surf Meets the Turf @Del Mar, CA
>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.