[SQL] Duplicates Processing

2010-10-08 Thread Gary Chambers
All, I've been provided a CSV file of parts that contains duplicates of properties (e.g. resistors have a wattage, tolerance, and temperature coefficient property) of those parts that differ by a manufacturer part number. What I'd like to do is to process this file and, upon encountering one of t

Re: [SQL] Duplicates Processing

2010-10-08 Thread Tim Landscheidt
Gary Chambers wrote: > I've been provided a CSV file of parts that contains duplicates of > properties (e.g. resistors have a wattage, tolerance, and temperature > coefficient property) of those parts that differ by a manufacturer > part number. What I'd like to do is to process this file and, u

Re: [SQL] Duplicates Processing

2010-10-08 Thread Gary Chambers
Tim, Thanks for taking the time to reply! > | INSERT INTO substitutes ([...]) > |   SELECT [...] FROM > |     (SELECT *, > |             ROW_NUMBER() OVER (PARTITION BY wattage, tolerance, temperature > |                         ORDER BY part_number) AS RN > |      FROM parts) AS SubQuery > |   W

Re: [SQL] Duplicates Processing

2010-10-08 Thread Rob Sargent
On 10/08/2010 01:42 PM, Gary Chambers wrote: > Tim, > > Thanks for taking the time to reply! > >> | INSERT INTO substitutes ([...]) >> | SELECT [...] FROM >> | (SELECT *, >> | ROW_NUMBER() OVER (PARTITION BY wattage, tolerance, temperature >> | ORDER BY

Re: [SQL] Duplicates Processing

2010-10-08 Thread Gary Chambers
Rob, > Perhaps a trade off between nullable fields and redundant types.  If > your original table simply had a nullable column called > isReplacementFor, into which you place in the subsequent rows the id of > the first instance found. Am I misunderstanding you when you're suggesting a table like

Re: [SQL] Duplicates Processing

2010-10-08 Thread Rob Sargent
Yes. With this you can find all part numbers/supplies which match your value, wattage criteria in one table. Or exclude any which have a non-null is_replacement_for value. If you need to drop the "replaceable" variant, you choose which of the replacements to promote and update the others to match

Re: [SQL] Duplicates Processing

2010-10-08 Thread Gary Chambers
Rob, > Yes.  With this you can find all part numbers/supplies which match your > value, wattage criteria in one table. Or exclude any which have a > non-null is_replacement_for value. I understand -- thanks. I have received contradictory advice in a purely data modeling context. What about the

[SQL] counting related rows

2010-10-08 Thread James Cloos
I have a table which includes a text column containing posix-style paths. Ie, matching the regexp "^[^/]+(/[^/]+)*$". I need to do a query of a number of columns from that table, plus the count of rows which are "children" of the current row. The query: SELECT count(*) AS nch FROM m WHERE o =

Re: [SQL] counting related rows

2010-10-08 Thread Frank Bax
James Cloos wrote: I have a table which includes a text column containing posix-style paths. Ie, matching the regexp "^[^/]+(/[^/]+)*$". I need to do a query of a number of columns from that table, plus the count of rows which are "children" of the current row. The query: SELECT count(*) AS

Re: [SQL] Duplicates Processing

2010-10-08 Thread Rob Sargent
My understanding was that the values were in fact in the data of the "replacers". If not, you are correct. In this case the replacers are more like alias for the only instance you have. If the replacers are immutable by all means ship them off to some other table (where I suppose the become poi