I have table X, and each record in X has many records in Y.  

I want a simple SQL which brings just the records from X which has the same set of records from Y.  

Each group of records from X I want it to be distinguished from other group (which has another set of records from Y) with some value.  

Example:

```
1 - 5
  - 6
2 - 3
3 - 5
  - 6
4 - 3
5 - 7

```

I want it back as:

```
1 - a
3 - a
2 - b
4 - b
5 - c

```