Hi everyone,
I am trying to make a PIVOT table + aggragate data that I cannot quite get working. It is from only two tables.
TicketPayments:
[fkTicketID][intType][decValue]
Tickets:
[pkTicketID][dtDate][intCount][boolPaid]
My goal is to have a query return a table in the following format.
[1][2][3][4][5][Sum(intCount)]
Columes 1-5 are the 5 types found in [intType]. Here is the working PIVOT portion I have. This is getting me a table of the format [1][2][3][4][5].
I cannot figure how to add the [SUM(intCount)] column to the returned table.Code:SELECT [1], [2], [3], [4], [5] FROM (SELECT intType, decValue, fkTicketID FROM TicketPayments) o PIVOT (SUM(decValue) FOR intType IN([1],[2],[3],[4],[5])) p JOIN Tickets c ON p.fkTicketID = c.pkTicketID
Any points on what I am missing?




Reply With Quote
