SELECT *
FROM (
SELECT item_id, fiscal_period, revenue
FROM (db)
WHERE (whereclause)'
) p
PIVOT
(
SUM(revenue)
FOR fiscal_period
IN ([1], [2], [3], [4], [5], [6])
) as revpiv
order by item_id
SELECT *
FROM (
SELECT item_id, fiscal_period, revenue, units
FROM (db)
WHERE (whereclause)'
) p
PIVOT
(
SUM(revenue)
FOR fiscal_period
IN ([1], [2], [3], [4], [5], [6])
) as revpiv
PIVOT
(
SUM(units)
FOR fiscal_period
IN ([1], [2], [3], [4], [5], [6])
) as unpiv
order by item_id
The column name "1" specified in the PIVOT operator conflicts with the existing column name in the PIVOT argument.and
Invalid column name 'fiscal_period'.and
The column '1' was specified multiple times for 'unpiv'.
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE