I have a resultset structure like this
ID Value Name
1 Oranges Reponse
1 42 Count
2 Apples Reponse
2 65
this was always such a chore pre sql server 2005.
now i use PIVOT/UNPIVOT
SELECT a.ID, a.Value AS [Response], b.Value AS [Count]
FROM your_table AS a
INNER JOIN your_table AS b
ON a.ID = b.ID
WHERE a.Name = 'Response'
AND b.Name = 'Count'
SELECT A.ID, A.VALUE RESPONSE, C.VALUE COUNT
FROM _table A
INNER JOIN (
SELECT ID, VALUE, NAME
FROM _table
WHERE _table.Name = 'Count'
) C ON A.ID = C.ID
WHERE A.NAME='Response' and C.NAME='Count'