Results 1 to 3 of 3
  1. #1
    joo-joo-man is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2010
    Posts
    2

    Question help counting distinct values

    Hi there,

    I'm a total beginner at SQL and Access and I'm having trouble writing a query. Hopefully somebody will steer me in the right direction and I will learn something in the process.

    I am working with a Chess database that tracks clubs, players, tournaments etc. I need to write a query to extract the player id, name, number of tournaments played in and the number of placings (1st, 2nd, 3rd) won for each player.

    There are usually different events at each tournament, so a player can technically gain more than one placing at a single tournament (e.g. 1st in one event, 2nd in another for example).

    Therefore, I want to extract only the unique number of tournaments a player has entered, and the total number of placings they have achieved (e.g. Bob Smith entered 3 tournaments and achieved 5 total placings).

    The way I have my query set up now (see below), it would extract 5 tournaments entered and 5 total placings achieved for Bob Smith. My question is, how can I make my query only select the distinct number of tournaments and placings?


    SELECT Player.Player_ID AS ID, (Player_lname + ", " + Player_fname) AS NAME, COUNT(Tournament_ID) AS numOfTournaments, COUNT(Placing_ID) AS numOfPlacings
    FROM Player, Representative, Contestant, Placing
    WHERE Player.Player_ID = Representative.Player_ID AND Representative.Rep_ID = Contestant.Rep_ID AND Contestant.Cont_ID = Placing.Cont_ID
    GROUP BY Player.Player_ID, Player_fname, Player_lname
    ORDER BY COUNT(Placing_ID) DESC;


  2. #2
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    I'm not exactly sure if this is what you're looking for but it might be a useful function for getting a distinct count:

    ECount

  3. #3
    joo-joo-man is offline Novice
    Windows XP Access 2000
    Join Date
    Oct 2010
    Posts
    2
    Thanks for the reply, but I still haven't figured it out

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Need help for distinct...
    By gunapriyan in forum Queries
    Replies: 2
    Last Post: 05-28-2010, 12:18 AM
  2. Replies: 2
    Last Post: 11-18-2009, 06:49 PM
  3. Distinct Values
    By Acramer8 in forum Reports
    Replies: 1
    Last Post: 06-15-2009, 08:37 AM
  4. Replies: 1
    Last Post: 11-11-2006, 08:00 PM
  5. Counting distinct id's
    By jqljql in forum Access
    Replies: 1
    Last Post: 09-01-2006, 07:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums