Reputation: 39
I have been struggling with this query for some time now. I get the following error:
Error in WHERE clause near 'PIVOT'
Unable to parse query text.
My query currently looks like this:
SELECT *
FROM
(
SELECT tblDatCash.colDate as dt , tblDatCash.colAccount as acc,
tblDatCash.colCash as cash
FROM tblDatCash
WHERE tblDatCash.colAccount = '5002680000CHF' or tblDatCash.colAccount ='5002680000EUR'
) DataTable
PIVOT
(
sum( [cash])
FOR [acc] IN ([5002680000CHF], [5002680000EUR])
) AS PIVOT
To make things clearer, here is an extract of what is in the table tblDatCash:
colAccount colCash colDate
02300000407319600000H 1512.83 2015-08-17 00:00:00.000
02300000362949610000Y 16537855.97 2015-08-17 00:00:00.000
5002680000CHF 3228530.89 2015-08-17 00:00:00.000
5002680000EUR 133825.33 2015-08-17 00:00:00.000
5002680000USD 694247.14 2015-08-17 00:00:00.000
Can anyone help me out on this?
Upvotes: 1
Views: 51
Reputation: 44921
You're using the PIVOT
keyword as a table alias on the last line of the query which you can't do. Change it to:
) AS P
or something else that is not a keyword.
Upvotes: 1