Pivoting with an extra field
Posted: Fri Sep 30, 2011 4:17 pm
Hi,
This example explains what I want to pivot:
How can I do that?
Thanks
This example explains what I want to pivot:
Code: Select all
Table 1. Simple pivot operation - input data
+-----------------------------------------------------------+
| REPID | last_name | Jan_sales | Feb_sales | Mar_sales |
|-----------+-----------+-----------+-----------+-----------|
| 100 | Smith | 1234.08 | 1456.80 | 1578.00 |
|-----------+-----------+-----------+-----------+-----------|
| 101 | Yamada | 1245.20 | 1765.00 | 1934.22 |
+-----------------------------------------------------------+
Table 2. Simple pivot operation - output data
+--------------------------------------------------------+
| REPID | last_name | Pivot_desc | Q1sales |
|-------------+-------------+--------------+-------------|
| 100 | Smith | Jan_sales | 1234.08 |
|-------------+-------------+--------------+-------------|
| 100 | Smith | Feb_sales | 1456.80 |
|-------------+-------------+--------------+-------------|
| 100 | Smith | Mar_sales | 1578.00 |
|-------------+-------------+--------------+-------------|
. . .
Thanks