I have a table in the form
Column A: String Column B: Integer
These are the only columns and they both form the PK.
Sample data:
| Column A | Column B |
|---|---|
| 'abc' | 1 |
| 'abc' | 2 |
| 'abc' | 3 |
| 'def' | 1 |
| 'def' | 3 |
| 'ghi' | 3 |
I need a view that gives me the intersection of column B for all values of A from the query.
I have already asked a few AIs, but without any meaningful results.
Expectation: select A, B from myView where A in ('abc','def','ghi') which returns B=3 since 3 is the intersection of the values of B for all values of A from the query.
The best result would be (to be able to continue joining)
| Column A | Column B |
|---|---|
| 'abc' | 3 |
| 'def' | 3 |
| 'ghi' | 3 |
No extension should be necessary for this.
Thanks for your help and ideas :)
array_agg(b) … GROUP BY a. It could then compute the intersection of{1, 2, 3},{2, 3}and{3}to{3}.