mds1256 Posted July 13, 2013 Share Posted July 13, 2013 (edited) Hi I am faced with the following problem. My table is as follows: part_idsupplier_idcustomer_id p1s1c1 p2s1c1 p3s2c1 p4s2c2 p5s1c2 And I need to return all customer ids where the customer has bought a part from the same supplier more than once. Any help would be appreciated Edited July 13, 2013 by mds1256 Quote Link to comment Share on other sites More sharing options...
Solution mac_gyver Posted July 13, 2013 Solution Share Posted July 13, 2013 SELECT customer_id FROM your_table GROUP BY customer_id,supplier_id HAVING count(*) > 1 Quote Link to comment Share on other sites More sharing options...
mds1256 Posted July 13, 2013 Author Share Posted July 13, 2013 SELECT customer_id FROM your_table GROUP BY customer_id,supplier_id HAVING count(*) > 1 Thank you!!! That worked exactly, looks simple but have been trying to do this for around 4 hours Much appreciated. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.