So I am trying to dedupe a table and I need some help. Now I know that a table should have keys ect to keep dupes out of the table but this is a hold table where raw data is going in and getting cleaned.Here is what I have gotten so far.select * into #tempfrom details dwhere exists( select * from details as ddwhere dd.id = d.id anddd.number = d.number anddd.line_item = d.line_item anddd.op_code = d.op_code anddd.op_description = d.op_description anddd.labor_cost = d.labor_cost anddd.labor_sale = d.labor_sale anddd.misc_cost = d.misc_cost anddd.misc_sale = d.misc_sale anddd.part_cost = d.part_cost anddd.part_sale = d.part_sale anddd.pay_type = d.pay_type anddd.tech_name = d.tech_name anddd.advisor_number = d.advisor_number anddd.store_id = d.store_id and dd.detailsid > d.detailsid)delete from details where detailsid in (select distinct detailsid from #temp)drop table #temp_details
The problem I am having is getting the numbers to jive with what I have below and I dont know why.select id, number, line_item, op_code, op_description, labor_cost, labor_sale, misc_cost, misc_sale, part_cost, part_sale, pay_type, tech_name, advisor_number, store_id, count(*) fromdownloaded_details_data group by id, number, line_item, op_code, op_description, labor_cost, labor_sale, misc_cost, misc_sale, part_cost, part_sale, pay_type, tech_name, advisor_number, store_idHAVING count(*) > 1
I think they are the same thing but are giving different results.Any help would be great in helping me understand what I am doing wrong.Cheers