I'm trying to build a query from an Oracle 11g database to use in a report. I need to use two tables CONTACT and CONTACT\_EXT to get the data from, and compare the total amount of contacts over two date ranges.The tables are joined by ID's matching.

CONTACT:

```
ID | DATE
----------
1   12/12/2010
2   12/11/2010
3   14/09/2011

```

CONTACT\_EXT

```
 ID | TYPE
----------
1   MAIL
2   FAX
3   FAX  

```

So for example if I set period A to be between 01/01/2010 and 12/12/2010 and period B to be between 01/01/2011 and 11/11/2011

```
TYPE | PERIOD A | PERIOD B | TOTAL
MAIL   1          0          1
FAX    1          1          2

```