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 2008 Forums
 Transact-SQL (2008)
 trying to find duplicates

Author  Topic 

mayerl
Yak Posting Veteran

95 Posts

Posted - 2011-02-18 : 13:21:54
Afternoon,

I am trying to find duplicates in a table. The job would be duplicated but the location would not. The program they are using is expecting one location but people are entering two or more.

I have this so far:


select Job, COUNT(job), ---RTRIM(LTRIM(TagNumber))as tagno,
case when i.TagNumber between 1000 and 3999 then 'Charlestown'
when i.TagNumber between 4000 and 4099 then 'Toolroom'
when i.TagNumber between 4100 and 4124 then 'Plating'
when i.TagNumber between 4125 and 4199 then 'Diamond Turning'
when i.TagNumber between 4200 and 4244 then 'Flycut'
when i.TagNumber between 4245 and 4319 then 'Coating'
when i.TagNumber between 4320 and 4359 then 'Post Polish'
when i.TagNumber between 4360 and 4534 then 'QA'
when i.TagNumber between 4535 and 4549 then 'Nitrogen Cabinet'
when i.TagNumber between 4550 and 4659 then 'Refractive'
when i.TagNumber between 4650 and 4659 then 'Shipping'
when i.TagNumber between 4660 and 4759 then 'RMR'
when i.TagNumber between 4760 and 4769 then 'Assembly'
when i.TagNumber between 4770 and 4819 then 'Misc'
when i.TagNumber between 4820 and 4850 then 'Wip'
when i.TagNumber between 4851 and 4875 then 'Coating'
when i.TagNumber between 6000 and 6499 then 'Vendors'
when i.TagNumber between 82008 and 83999 then 'Keene'
else 'Unknown'
end tag_loc
from InventoryWipTags i
group by job,TagNumber
having COUNT(job)>1
order by job


But I want to see which ones have one job but more than one location like this one:

job tag loc
405425 Charlestown
405425 Coating
406987 Coating
406997 Charlestown
407361 Toolroom
407391 Coating
407551 Toolroom
407571 Charlestown

I want it to tell me 405425 is an error. Can someone help me?

Any thoughts would be appreciated.

Thanks

Laura

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-02-18 : 13:56:01
in the mentioned output it seems every job is repeating not just 405425 one?? Can you post few rows of data of your InventoryWipTags and the required output format in light of those rows...
Go to Top of Page

mayerl
Yak Posting Veteran

95 Posts

Posted - 2011-02-18 : 17:03:14
Thanks for getting back to me. I got it. It wasn't this after all. something else was breaking the program. Thanks again though for helping.

Laura
Go to Top of Page
   

- Advertisement -