i have a query that gives me orientation one way and i need it the other.
like
co1 widg1 1321 12/4/12 3
co1 widg2 1322 12/4/12 2
co1 widg1 1321 12/11/12 1
co1 widg1 1321 12/18/12 1
co1 widg2 1322 12/18/12 4
co1 widg2 1322 12/25/12 2
co1 widg1 1321 12/25/12 3
i need it like
12/4/12 12/11/12 12/18/12 12/25/12
co1 widg1 1321 3 1 1 2
co1 widg2 1322 2 0 4 3
i could do it brute force in a program, but if i could get a query to feed it to me in the orentation i need that would be great.
i am feeling it might have something to do with the PIVOT
here is the query i am using
SELECT CT.CTCoName, CTDet.CTDetDesc, CTDet.CTDetProd, CT.CTDate, COUNT(*) AS Expr1
FROM CT INNER JOIN
CTDet ON CT.CTID = CTDet.CTID
WHERE (CTDet.CTDetSorted IS NOT NULL)
GROUP BY CTDet.CTDetDesc, CTDet.CTDetProd, CT.CTDate, CT.CTCoName
HAVING (CTDet.CTDetProd LIKE '%widg%') AND (CT.CTDate > CONVERT(DATETIME, '2012-10-02 00:00:00', 102)) AND
(CT.CTCoName = 'co1')
ORDER BY CT.CTDate, CT.CTCoName