Skip to content
Advertisement

Select based on group membership

Suppose I have two tables t and o. I want to select all the rows of t in which t.feature = o.feature (ergo first two rows).

In addition, I also want to select all the rows whose t.grouping = t.grouping of the previously selected rows. In this case t.grouping 1, 2 ergo rows ('E', 1), ('F', 2) and ('G', 1). What is the most elegant way of achieving this?

Advertisement

Answer

If I understood correctly try this…

or

DEMO

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