-- Find duplicate vendors
SELECT
    vendor,
    COUNT(*) as count,
    GROUP_CONCAT(vendorid ORDER BY vendorid) as vendor_ids
FROM vendors
GROUP BY LOWER(TRIM(vendor))
HAVING COUNT(*) > 1
ORDER BY count DESC, vendor;

-- Find duplicate models
SELECT
    modelnumber,
    vendorid,
    COUNT(*) as count,
    GROUP_CONCAT(modelnumberid ORDER BY modelnumberid) as model_ids
FROM models
GROUP BY LOWER(TRIM(modelnumber)), vendorid
HAVING COUNT(*) > 1
ORDER BY count DESC, modelnumber;

-- Find vendors with case/spacing differences
SELECT
    vendor,
    vendorid,
    LOWER(TRIM(vendor)) as normalized
FROM vendors
ORDER BY normalized, vendorid;
