Consulting

Results 1 to 2 of 2

Thread: Count different names

  1. #1
    VBAX Regular
    Joined
    Aug 2005
    Posts
    77
    Location

    Count different names

    Hello!

    I have many names in column "Name". Now i want count different names in column "Name"
    Earlier using 2 queries. first group and second count but is any fastest way and using 1 query?

  2. #2
    VBAX Regular
    Joined
    Aug 2004
    Location
    London, England
    Posts
    52
    Location
    Really you need COUNT(DISTINCT Name) but I don't think Access will let you do this. A nested query usually works, though the access sql editor sometimes does funny things with these queries after you save them.

    SELECT COUNT(*) FROM
    (
    SELECT DISTINCT [fieldname] FROM [tablename]
    )

    You could also save the subquery as a query in its own right, so you could have

    qryDistinctNames = 'SELECT DISTINCT [Name] FROM TableName'

    and

    qryDistinctNameCount = 'SELECT COUNT(*) FROM qryDistinctNames'

    However, there's probably a nicer way of doing this, which I'm sure someone will tell us!

Posting Permissions

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