Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Combining 2 SKUs
Message
From
22/07/2002 11:30:48
James Hansen
Canyon Country Consulting
Flagstaff, Arizona, United States
 
 
To
19/07/2002 14:20:36
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00680493
Message ID:
00681170
Views:
18
Let me restate the issue to see if I understand correctly: There are duplicate records in the database with the same SKU, Color, etc. and you want to total the amounts for each Location into one record, eliminating the duplication of SKU's. Or did I miss the point?

If the tables are free tables or if they are in a DBC and the field names are 10 characters or less, you should be able to do this with a SQL SELECT, summing on the Location fields and Grouping by the the fields that distinguish the records to be combined. For example, if the SKU alone uniquely identifies the records to combine it might look something like:

select SKU, ;
Item, ;
Color, ;
... ;
sum(Location1) as Location1, ;
sum(Location2) as Location2,
... ;
from Table1 ;
into Table2 ;
group by SKU

(Elipses indicate additional fields not listed to include all fields.)

If the SKU and Color combined identify the record uniquely, just change: "group by SKU, Color"

You can then ZAP the original tables (after backing them up, of course), and Append from the new table, thus preserving indexes.

Doing this with field names longer than 10 characters in a DBC is more complicated, but could be done with some programming, selecting the fields with names longer than 10 characters using AS to give them a new name, then writing code to SCAN the new table and copy the records back using a SQL INSERT command.

I hope that helps and is in the ballpark of where you want to go.

...Jim


>Examples of my data file:
>
>SKU: 99999
>Item: widget
>Color: blue
>Location 1: 5
>Location 2: 3
>Location 3: 4
>
>The problem that I am having: this client has many duplicate sku's (each with their own quantities). The duplicates need to be combined and one (of the two) needs to be deleted.
>
>Thanks, Randy
Previous
Reply
Map
View

Click here to load this message in the networking platform