Skip to content
Advertisement

oracle sql find overlapping values between two sets

I have two tables (‘stock’, ‘website’) have the same structure both has one called ‘product_id’ I want to find out in what percentage the product_id in the ‘website’ table also in ‘stock’ table

Did not find an easy way to achieve. Hope to get some suggestion. tried INTERSECT operator

Advertisement

Answer

You can achieve this by using an outer join and then counting the product ids in each table, and then working out the percentage, e.g.:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement