Chance1234
IS-IT--Management
have read the pivot operator on bol and a few examples on the web. Unfortunatly dont have any of the sample databases, so can't actually see the pivot command working.
I am trying to convert this Access query to SQL
The field domain_quarter contains Q1, Q2, etc which is what i want going across the top.
Ive played around with
But could really do with some pointers where I am going wrong.
Chance,
Filmmaker, gentleman and polla stilo eleous
I am trying to convert this Access query to SQL
Code:
TRANSFORM Max(dbo_v_kpi_front_page.indicator_results_result) AS MaxOfindicator_results_result
SELECT dbo_v_kpi_front_page.domain_year, dbo_v_kpi_front_page.heading
FROM dbo_v_kpi_front_page
GROUP BY dbo_v_kpi_front_page.domain_year, dbo_v_kpi_front_page.heading
PIVOT dbo_v_kpi_front_page.domain_quarter
The field domain_quarter contains Q1, Q2, etc which is what i want going across the top.
Ive played around with
Code:
SELECT
domain_quarter,
Q1 = ISNULL([Q1], 0),
Q2 = ISNULL([Q2], 0),
Q3 = ISNULL([Q3], 0),
Q4 = ISNULL([Q4], 0)
FROM
v_kpi_front_page
PIVOT (
SUM(indicator_results_result)
FOR domain_quarter IN ([Q1], [Q2], [Q3], [Q4])
) AS Indicator
But could really do with some pointers where I am going wrong.
Chance,
Filmmaker, gentleman and polla stilo eleous