Results 1 to 5 of 5

Thread: Count of specific records

  1. #1
    Join Date
    Jan 2004
    Posts
    2

    Count of specific records

    I'm having problems constructing a query. I need to get a count of emails in my database, but only the emails that appear 2 or more times.
    Can anyone help?

    Thanks!
    Justine

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Try

    select count(email) total from Table group by email having count(email) > 1

  3. #3
    Join Date
    Jan 2004
    Posts
    2
    Thanks so much! It worked beautifully!

    -Justine

  4. #4
    Join Date
    Feb 2004
    Posts
    2
    what is your approach to this script if you need to include a where line to limit the range in which you are evaluating the table for duplicates. Lets say, using the example that started the thread, I want to gather duplicates for e-mails, but only for those rows where the State field = 'MI'

    How would that work with this script?

  5. #5
    Join Date
    Feb 2004
    Posts
    2
    Never mind...I answered my own question...

    select * from EmpAddresses where email in (select email from EmpAddresses group by email having count(email) > 1)
    and state = 'MI'

Posting Permissions

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