Checking the uniqueness of data

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Griff (Howling_at_The.Moon)
Date: 10/22/04


Date: Fri, 22 Oct 2004 14:12:01 +0100

I have a very large table containing user details.

There are two columns of interest, "userName" and "accountName".

I wish to use SQL to interrogate this table to find out how many non-unique
userNames there are for each accountName.

I.e., if accountName = "Development" and all the userNames are unique, then
I'd want to retrieve the value 0. If the accountName is "Marketing" and
there are 12 Sharons, 15 Paulas and 8 Robins, but all the rest were unique,
I'd want the value 3 (i.e. three names that were not unique).

However, I've no idea how to achieve this in SQL. Any clues much
appreciated.

Many thanks in advance

Griff



Relevant Pages

  • Re: Dynamic SQL question
    ... If you are going the Dynamic SQL way, ... > I need to build a where clause for my SQL query. ... > declare @where varchar ... > declare @AccountName varchar ...
    (microsoft.public.sqlserver.programming)
  • Re: SMS 2.0 - Remote tools being denied
    ... SQL query "SELECT * FROM SecurityObjUsers" against your SMS DB. ... of the case used on the usernames and compare to that found in the ... > that I am working on or the client workstation I am trying to access? ...
    (microsoft.public.sms.admin)
  • Microsoft SQL Server password cracking
    ... lists in order to halt some worries. ... The password cracker relies on getting access to the hashes that SQL ... It CANNOT work by simply pointing it at an MS SQL server. ... NT usernames and passwords. ...
    (NT-Bugtraq)
  • Re: Dynamic SQL question
    ... AccountName + ''' ' ... you should note that you're opening yourself up for SQL injection ... arguments and dynamic SQL: ... > declare @ID int ...
    (microsoft.public.sqlserver.programming)
  • Re: Checking the uniqueness of data
    ... Columnist, SQL Server Professional ...
    (microsoft.public.sqlserver.programming)