Click here to Skip to main content
15,905,785 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have data in the following format in sql server 2008

userid   testid   catid    correct      incorrect
2         1        1       18           NULL
2         1        2        1           NULL
2         1        1       NULL          5
2         1        2       NULL           1


i have to make it into the following format:
userid   testid   catid    correct      incorrect
2         1        1       18           5
2         1        2        1           1

please help me to solve the problem.
Posted
Updated 21-Aug-13 3:02am
v2

1 solution

You may try this:
SQL
SELECT userid, testid, catid, max(correct), max(incorrect)
FROM [your table]
GROUP BY userid, testid, catid
 
Share this answer
 
Comments
Maciej Los 21-Aug-13 9:59am    
+5!
viky.singh 22-Aug-13 5:23am    
thanks buddy it works fine.
thanh_bkhn 22-Aug-13 5:27am    
Thanks Maciej
viky.singh 22-Aug-13 6:46am    
thanks buddy your solutions works fine..

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