quote:
Since you are ignoring NULLS then this I think is what you are looking for is something like this.
SELECT
(CASE WHEN ProdA = 1 THEN 'A' ELSE '' END) +
(CASE WHEN ProdB = 1 THEN 'B' ELSE '' END) +
(CASE WHEN ProdC = 1 THEN 'C' ELSE '' END) AS Combination,
COUNT(*) as Resp
FROM
(
SELECT
Resp,
SUM(CASE WHEN ProdName = 'A' AND Value = 'Yes' Then 1 Else 0 END) AS ProdA,
SUM(CASE WHEN ProdName = 'B' AND Value = 'Yes' Then 1 Else 0 END) AS ProdB,
SUM(CASE WHEN ProdName = 'C' AND Value = 'Yes' Then 1 Else 0 END) AS ProdC
FROM
tblResponses
GROUP BY
Resp
) AS tblPivot
GROUP BY
ProdA,
ProdB,
ProdCEdited by - antares686 on 05/07/2003 04:58:11 AM
This does not solve the problem. It does not provide results for all the combinations.
Also note that the 3 products is just an example we would have about 30 products.
For most cross-tabulation type problems a really good tool is the RAC (Replacment for Access Cross tabulation) stored procedures, if that helps.
Regards
Edited by - AKshah1 on 05/07/2003 05:24:12 AM
Edited by - AKshah1 on 05/07/2003 05:27:28 AM