I've been banging my head against my keyboard trying to get this to work. Here's how my simple two column table (named "Test") looks:
part_id cust_id
1..........1
1..........1
2..........2
3..........3
I need to write a select statement that will list all cust_id that ordered the same part_id more than once and also lists the part_id. So far the closest I've been able to come is:
SELECT cust_id, COUNT(part_id)
FROM TEST
GROUP BY cust_id
HAVING COUNT(part_id) > 1;
Which only tells me how many customers ordered more that one part. The same part_id is the key here. Any tips would be greatly appreciated!
cust_idinstead ofcustomer_id? Otherwise the query looks fine.