Does any one know how to create crosstab queries in PostgreSQL? For example I have two following tables:
TABLE A
| ID 1 | ID 2 | ID 3 |
|:-----------|------------:|:------------:|
| 00001 | 01 | 0001 |
| 00001 | 02 | 0001 |
| 00001 | 01 | 0002 |
TABLE B
| ID 1 | ID 2 | ID 3 | price | tax_rate |
|:-----------|------------:|:------------:|:------------:|:------------:|
| 00001 | 01 | 0001 |5000 | 8 |
| 00001 | 01 | 0001 |6000 | 10 |
I would like the query to return the following crosstab:
| ID 1 | ID 2 | ID 3 | price_8 | price_10 |
|:-----------|------------:|:------------:|:------------:|:------------:|
| 00001 | 01 | 0001 |5000 | 6000 |
| 00001 | 02 | 0001 |null | null |
| 00001 | 01 | 0002 |null | null |
Is this possible?