Skip to content
Advertisement

SQL Select to display one to one, one to many from many to many relation

I’m trying to figure out SQL query that will list only one to one relation from below table.

Below Table contain 10 record where 8 are many to many relation data and 2 are one to one relation. Request your help with SQL that I can use to query below table and list out 2 records that has one to one relation. Note: Table support many to many relation.

Table1:

enter image description here

Advertisement

Answer

You can use window functions:

You can also use not exists:

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