I'm working with JASPERREPORT, I have to create an SQL Query to have the right report I have tow tables in my databases like :
**Columns**:
|Column's numbre |column's description |
|----------------|---------------------|
| 1 | X |
| 2 | Y |
| 3 | Z |
**Tableau**:
|LINE.NUMBRE |COLUMN.NUMBRE |CELLE.CONTENT|
|--------------|----------------|------------ |
| 1 | 1 |A |
| 1 | 2 |B |
| 1 | 3 |C |
| 2 | 1 |D |
| 2 | 2 |E |
| 2 | 3 |F |
And in my report I want to have this Table
| X | Y | Z |
|-----|-----|-----|
| A | B | C |
| D | E | F |
I tried this QUERY:
SELECT F_ROW_LABEL1, F_ROW_LABEL2, F_ROW_LABEL3
FROM
(SELECT T.LIGNE_NUMBRE , T.COLUMN_NUMBRE, T.CELL_CONTENT
FROM TABLEAU T , COLUMNS C
WHERE --Conditions
AND C.COLUMN_NUMBRE= T.COLUMN_NUMBRE
)
PIVOT (CELL_CONTENT FOR (COLUMN_NUMBRE) IN (1 AS F_ROW_LABEL1, 2 AS F_ROW_LABEL2, 3 AS F_ROW_LABEL3))
And I have this result:
|F_ROW_LABEL1| F_ROW_LABEL2| F_ROW_LABEL3|
|------------|-------------|-------------|
| A | B | C |
| D | E | F |
The rest is how can I return the column's header from my query.
Thanks,