Part numbers with multiple descriptions.

R

rapid1

I have a db with 100k sku's in 165 locations. Each sku is supposed to have
the same description across all locations but some do not. I need to write a
query that will filter for only part numbers with more than 1 description
assigned. I was thinking I could do it with only the Part Number, Location
and Description fields? Anyway, any help would be much appreciated!
 
K

Ken Sheridan

Try this:

SELECT Sku, Description
FROM YourTable AS T1
GROUP BY Sku,Description
HAVING COUNT(*) <
(SELECT COUNT(*)
FROM YourTable AS T2
WHERE T2.Sku = T1.Sku);

Your problem arises of course from the redundancy of the Description column
in the table. This should only be a column in a separate related table with
one row per sku, which is then related to the table including the locations
on the sku columns.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top