Click here to Skip to main content
15,302,857 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
TestID Testname Remarks
1     Quartely       "Do you have ção":"Algodão"
2     Halferly       "Do you have próximo":"Não"
3     Annually       "Do you have Irá Ajudar":"No"

from the above i want output as follows
TestId Testname Do you have ção     Do you have próximo        Do you  have Irá Ajudar
1    Quartely    Algodão                 Não                        No

My sql query as follows
SQL
SELECT A.Test_id,B.Testname,C.Remarks from studendetails
innerjoin tblstduent on B.Testid=C.Testid
where b.Testid IS NOT NULL

from my above sql query what changes i have to made to get the above output

What I have tried:

TestID Testname Remarks

1 Quartely "Do you have ção":"Algodão"
2 Halferly "Do you have próximo":"Não"
3 Annually "Do you have Irá Ajudar":"No"


from the above i want output as follows

TestId Testname Do you have ção Do you have próximo Do you have Irá Ajudar

1 Quartely Algodão Não No


My sql query as follows

SELECT A.Test_id,B.Testname,C.Remarks from studendetails
innerjoin tblstduent on B.Testid=C.Testid
where b.Testid IS NOT NULL

from my above sql query what changes i have to made to get the above output
Posted
Updated 30-Apr-18 21:25pm
v3

   
You could start with something like
SQL
SELECT [Quartely], [Halferly], [Annually]
FROM ( SELECT testname, remarks
       FROM YourTable) AS a
PIVOT ( MAX(remarks) 
        FOR testname IN ([Quartely], [Halferly], [Annually])) AS b

However, in order to get the answer, you need to split the for example result based on the location of : character
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900