Results 1 to 4 of 4
  1. #1
    Lounger
    Join Date
    Jun 2002
    Location
    Michigan City, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Count unique values in a field (2000)

    So far I have a query that looks like this:

    SELECT tblAppointment.Term, tblAdvisingCode.AdvisingCode, Sum([Duration])/60 AS [Number of Contact Hours], Count(tblAppointment.AID) AS [Number of Contacts], Count(tblAppointment.SID) AS CountOfSID
    FROM tblAppointment INNER JOIN tblAdvisingCode ON tblAppointment.AID = tblAdvisingCode.AID
    WHERE (((tblAppointment.Term)=[Which semester? eg SP03]))
    GROUP BY tblAppointment.Term, tblAdvisingCode.AdvisingCode;

    This gives me each advising code, the number of contact hours for each code. What I need is a number of how many unique participants had an appt with that code. For instance, I have 22 academic advising contacts, but there should only be 18 participants (these are in [SID]), some had more than one academic advising contact. How do I get it to count just the distinct values. I tried turning on unique values and that didn't work. I've tried count, tried select distinct. Help! This is making me crazy!

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Count unique values in a field (2000)

    What you have is going to select AdvisingCode by Term. What is Term?
    Take out Term and see what you get.
    Pat <img src=/S/cheers.gif border=0 alt=cheers width=30 height=16>

  3. #3
    Lounger
    Join Date
    Jun 2002
    Location
    Michigan City, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Count unique values in a field (2000)

    Term is the semester in which the student had the appointment. I need to be able to select which term I want.

  4. #4
    Super Moderator
    Join Date
    Aug 2001
    Location
    Evergreen, CO, USA
    Posts
    6,623
    Thanks
    3
    Thanked 60 Times in 60 Posts

    Re: Count unique values in a field (2000)

    In that case change the GroupBy for TERM to a WHERE - then the term isn't actually returned. Otherwise you need to consider a CROSSTAB query or Pivot table if you need to show more than one semester.
    Wendell

Posting Permissions

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