I think my question is very simple and the answer must be simple too. I just want something like a pivot on one of my three columns. I have a query like this :
SELECT AgentId, ReferenceTitle, PaymentValue FROM AgentPayments WHERE PaymentValue > 0
the result will be something like this :
AgentId ReferenceTitle PaymentValue
---------------------------------------------------
AgentId1 ReferenceTitle1 PayementValue1
AgentId1 ReferenceTitle2 PayementValue2
AgentId1 ReferenceTitle3 PayementValue3
AgentId2 ReferenceTitle2 PayementValue4
AgentId3 ReferenceTitle2 PayementValue5
AgentId3 ReferenceTitle3 PayementValue6
it returns some records for me as you see, now i want to convert the result in a way that each value of column 'ReferenceTitle' become a column for itself like below :
AgentId ReferenceTitle1 ReferenceTitle2 ReferenceTitle3
--------------------------------------------------------------------
AgentId1 PayementValue1 PayementValue2 PayementValue3
AgentId2 NULL PayementValue4 NULL
AgentId3 NULL PayementValue5 PayementValue6
I just found very complicated results by searching, but I think there must be a simple solution. do you think like me?
UPDATE
I don't know the values of the 'ReferenceTitle' Column, so I can't use those values in my query.