Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Duplicate with different Ids

Author  Topic 

Onamuji
Aged Yak Warrior

504 Posts

Posted - 2001-07-19 : 08:52:31

Our department keeps a list of all its Teams/Business Units in a table and this table relates an employee id to a team, however they have changed the structure on me and made the reports appear to be broken since they relied on the teams table heavily. It's a very simple structure:
Teams
- Id
- EmployeeId
- Name
However, there can now be a Team.Name with the same name yet I need to group all those together somehow, while returning an id that will be recognized throughout the application. How about some sample data:

--- Team.Id --- Team.EmployeeId --- Team.Name ---
--------------------------------------------------------
--- 1...... --- 1.............. --- Marketing
--- 2...... --- 2.............. --- Technical Serivces
--- 3...... --- 3.............. --- Internet Development
--- 4...... --- 4.............. --- Internet Development
--- 5...... --- 5.............. --- Operations
--- 6...... --- 6.............. --- Operations
--------------------------------------------------------

As you can see there are Teams with the same name but different EmployeeId's. The employee id's are super important, that how other data is related to a team, based on who is the manager. If I use
-
select distinct Id, Name from Teams group by Name, Id order by Name

-
It will still return the duplicates, I have tried distinct but since I need the Id and the Name it's giving me muchos problems. I also need a query that will select a single team name for either id such that I have another table and I want to report the team name and that tables data yet have both of the EmployeeIds in the data table be summed...

Hope that's not too much thinking for you guys ;-)


Regards,
Adam
   

- Advertisement -