![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
my ci2 table: id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates across zones with the 4 columns in the group by making it unique. I only need to order 1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) How to change the select into a delete? I am reading on how to create a temp table. How do I get the unique records into the temp table? Then I drop the real table. tnx, |
#3
| |||
| |||
|
|
On 12-11-10 20:15, jr wrote: my ci2 table: id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates across zones with the 4 columns in the group by making it unique. I only need to order 1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) How to change the select into a delete? I am reading on how to create a temp table. How do I get the unique records into the temp table? Then I drop the real table. tnx, i'm sure its somewhere on this page: http://dev.mysql.com/doc/refman/5.0/en/delete.html |
#4
| |||
| |||
|
|
On 12-11-10 20:36, Luuk wrote: On 12-11-10 20:15, jr wrote: my ci2 table: id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates across zones with the 4 columns in the group by making it unique. I only need to order 1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) How to change the select into a delete? I am reading on how to create a temp table. How do I get the unique records into the temp table? Then I drop the real table. tnx, i'm sure its somewhere on this page: http://dev.mysql.com/doc/refman/5.0/en/delete.html without reading that page, you could also do: UPDATE ci2 SET businessunit=12345 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) (change the '12345' to any businessunitnumber you can recognize as deletable) and after that you can do a: DELETE from ci2 WHERE businessunit=12345 -- tnx, |
#5
| |||
| |||
|
|
On 12-11-10 20:36, Luuk wrote: On 12-11-10 20:15, jr wrote: my ci2 table: id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates across zones with the 4 columns in the group by making it unique. I only need to order 1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) How to change the select into a delete? I am reading on how to create a temp table. How do I get the unique records into the temp table? Then I drop the real table. tnx, i'm sure its somewhere on this page: http://dev.mysql.com/doc/refman/5.0/en/delete.html without reading that page, you could also do: UPDATE ci2 SET businessunit=12345 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) |
|
(change the '12345' to any businessunitnumber you can recognize as deletable) and after that you can do a: DELETE from ci2 WHERE businessunit=12345 |
#6
| |||
| |||
|
|
On 12-11-10 20:36, Luuk wrote: On 12-11-10 20:15, jr wrote: my ci2 table: id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates across zones with the 4 columns in the group by making it unique. I only need to order 1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) How to change the select into a delete? I am reading on how to create a temp table. How do I get the unique records into the temp table? Then I drop the real table. tnx, i'm sure its somewhere on this page: http://dev.mysql.com/doc/refman/5.0/en/delete.html without reading that page, you could also do: UPDATE ci2 SET businessunit=12345 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) (change the '12345' to any businessunitnumber you can recognize as deletable) and after that you can do a: DELETE from ci2 WHERE businessunit=12345 -- Luuk |
#7
| |||
| |||
|
|
On 12-11-10 20:36, Luuk wrote: On 12-11-10 20:15, jr wrote: my ci2 table: id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates across zones with the 4 columns in the group by making it unique. I only need to order 1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) How to change the select into a delete? I am reading on how to create a temp table. How do I get the unique records into the temp table? Then I drop the real table. tnx, i'm sure its somewhere on this page: http://dev.mysql.com/doc/refman/5.0/en/delete.html without reading that page, you could also do: UPDATE ci2 SET businessunit=12345 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*)> 1 ) (change the '12345' to any businessunitnumber you can recognize as deletable) and after that you can do a: DELETE from ci2 WHERE businessunit=12345 -- Luuk |
#8
| |||
| |||
|
|
my ci2 table: id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates across zones with the 4 columns in the group by making it unique. I only need to order 1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*) > 1 ) How to change the select into a delete? I am reading on how to create a temp table. How do I get the unique records into the temp table? Then I drop the real table. |
#9
| |||
| |||
|
|
On Fri, 12 Nov 2010 11:15:55 -0800 (PST), jr wrote: my ci2 *table: *id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates *across zones with the 4 columns in the group by making it unique. *I only need to order *1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*) > 1 ) How to change the select into a delete? I am reading on how to create a temp table. *How do I get the unique records into the temp table? *Then I drop the real table. slap an aggregate over all the columns? -- 34. I will not turn into a snake. It never helps. * * * * --Peter Anspach's list of things to do as an Evil Overlord |
#10
| |||
| |||
|
|
On Fri, 12 Nov 2010 11:15:55 -0800 (PST), jr wrote: my ci2 *table: *id,businessunit, zonenumber,zoneid, ndc There are 874 records that have 1 or more duplicates *across zones with the 4 columns in the group by making it unique. *I only need to order *1 per business unit, but the zones have more than one ndc across the zones. select * FROM ci2 WHERE ndc is not null GROUP BY businessunit,zonenm,zoneid,ndc HAVING ( COUNT(*) > 1 ) How to change the select into a delete? I am reading on how to create a temp table. *How do I get the unique records into the temp table? *Then I drop the real table. slap an aggregate over all the columns? |
![]() |
| Thread Tools | |
| Display Modes | |
| |