July 29, 2013 at 11:24 am
Hi
I'm getting the error message 'Incorrect syntax near PIVOT' when I try the following code as a view
SELECT year_, client, job, [Payroll] AS 'payr_perc', [Operational] AS 'oper_perc', [Administration] AS 'admin_perc', [Establishment] AS 'estab_perc',
[Financial] AS 'finan_perc', [Miscellaneous] AS 'misc_perc'
FROM (SELECT *
FROM dbo.budprepv_ExpAlloc_perc) ps PIVOT(SUM(Alloc_perc) FOR ExpHead IN ([Payroll], [Operational], [Administration], [Establishment],
[Financial], [Miscellaneous])) AS pvt
I can't see what's wronf! Could someone help me please?
Thanks
Dave
July 29, 2013 at 12:25 pm
Is PIVOT not recognised in SQL 2000? Maybe its only, SQL 2005.....
July 29, 2013 at 12:29 pm
That's correct. Pivot was introduced in SQL 2005.
You can use CASE to pivot in SQL 2000 (or all other versions for that matter). Here's an example:
July 29, 2013 at 12:59 pm
Thanks again.
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply