Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS-SQL - select using HAVING count(field-name) > 1

Status
Not open for further replies.

UHsoccer

Programmer
Apr 24, 2003
139
US
I am trying to identify duplicate entries in a data base table, using the following

SELECT *
FROM MyTable
WHERE (categoryId = 6) AND (categoryVal = '45')
HAVING (COUNT(CompanyId) > 1)

It fails referencing field number 1 (rKey) which is an automatically generated ID field.
Any help appreciated

 
Instead of selecting all columns(*) name your columns and leave out the identifier column. If you have to have it then try converting it to a varchar in the select statement.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top