Return unique rows in SQL Server 2008

stochzossa832

New Member
I have a SQL Server table with 2 ID columns: \[code\]Employee_ID & Type_ID\[/code\]My table contains 4 rows:\[code\]Row 1 (Employee ID: 904, Type_ID: 3)Row 2 (Employee ID: 904, Type_ID: 7)Row 3 (Employee ID: 905, Type_ID: 7)Row 4 (Employee ID: 905, Type_ID: 7)\[/code\]I want to return all the type ID's that are available for all employees. So just \[code\]ID 7\[/code\].So I want 1 row return with the ID of 7 as it is available for both employees (904 & 905)If I run the following SQL:\[code\]SELECT Type_ID, Count(Type_ID) as MyCount FROM EmployeeTypeWHERE Employee_ID IN (904, 905) GROUP BY Type_ID\[/code\]This returns me 2 rows\[code\]Row 1 (Type_ID: 3, MyCount: 1)Row 2 (Type_ID: 7, MyCount: 3)\[/code\]But I only what the record with the highest count (Type_ID 7). I tried adding:\[code\]HAVING MAX(Count(CostCentre_ID))\[/code\]But this is obvuiouly illegal code.How can I do this in my SQL?
 
Top