I have a table that looks a bit like this:
country | group | offer | type | list
--------|-------|-------|------|-----
UK | A | 1 | AA | 1
UK | A | 2 | BB | 1
UK | A | 3 | CC | 2
IE | A | 4 | AA | 2
IE | A | 5 | BB | 2
IE | A | 6 | CC | 1
UK | B | 7 | AA | 3
UK | B | 8 | BB | 4
UK | B | 9 | CC | 4
I want to return all rows where the following is true:
- Type = CC
- List value is shared with a row of type AA or BB that has the same group and country
So for example, my desired result would look like this:
country | group | offer | type | list
--------|-------|-------|------|-----
UK | B | 9 | CC | 4
This row would be returned because it's type is CC, and it has the same list number as other rows whose country is UK and group is B.
Does anyone know how this can be done please?