I've two database tables, one called "Headers" and one called "Rows".
The structure is:

```
Header: IDPK | Description
Row:    IDPK | IDPK_Header | Item_ID | Qty

```

I need to do a query that says: "From a Header, IDPK find another header that have the same number of rows and the same item ID and quantity".

For example:

```
Header             Rows
IDPK  Description  IDPK    Item_ID    Qty
 1    'Test1'       1        'A'      10
 1    'Test1'       2        'B'      20
 2    'Test2'       3        'A'      10
 2    'Test2'       4        'B'      20
 3    'Test3'       5        'A'      5
 3    'Test3'       6        'B'      20
 4    'Test4'       7        'A'      10

```

Header `Test1` match `Test2` but not `Test3` and `Test4`

The problem is that the number of rows must be exactly the same. I try with `ALL` operator but without luck.

How I can do the query with an eye for the performance? The two tables can be very huge (~500.000 records).