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.
| Author |
Topic |
|
PolarBear
Starting Member
5 Posts |
Posted - 2009-02-17 : 16:32:13
|
| I need to identify individuals that have multiple employers.Data from employment table as follows:Memb_id Employer_id1234 8561234 2471234 651444 916Seeking results as follows:Memb_ID Multilpe_employers1234 Y444 NAny assistance greatly appreciated.Regards,PolarBear |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-02-17 : 16:34:52
|
| [code]select memb_id ,case when count(distinct employer_id) > 1 then 'Y' else 'N' end as [Multiple_employers]from employmentgroup by memb_id[/code]Be One with the OptimizerTG |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2009-02-17 : 16:47:07
|
| [code]Select distinct Memb_id, (Case when Count(*) over(Partition by Memb_id)>1 then 'Y' Else 'N' End)as Multiple_Employersfrom Tableorder by Memb_id[/code] |
 |
|
|
PolarBear
Starting Member
5 Posts |
Posted - 2009-02-17 : 22:45:38
|
| Thanks very much for your responses. I now have the information that I required. It works great. I only wish I was more skilled at scripting! Great to see others share their expertise!Regards,PolarBear |
 |
|
|
|
|
|