Hope you can help.I'm trying to use COUNT and MAX to find the dominant Mosaic Type based on a count of households for an output area.The query: SELECT OA_CODE, MAX(FullTotals.Total) AS TopAnswerFROM DIM_OUTPUT_AREAINNER JOIN(SELECT [Output Area (Pc)], [Mosaic UK Type (Pc)], COUNT(id) AS TotalFROM FACT_MOSAIC_NLPGGROUP BY FACT_MOSAIC_NLPG.[Output Area (Pc)], [Mosaic UK Type (Pc)]) AS FullTotalsON FullTotals.[Output Area (Pc)] = DIM_OUTPUT_AREA.OA_CODEGroup By OA_CODEORDER BY OA_CODE ASC
Returns the output area and the highest total. But when I add in the mosaic code like this:SELECT OA_CODE, FullTotals.[Mosaic UK Type (Pc)], MAX(FullTotals.Total) AS TopAnswerFROM DIM_OUTPUT_AREAINNER JOIN(SELECT [Output Area (Pc)], [Mosaic UK Type (Pc)], COUNT(id) AS TotalFROM FACT_MOSAIC_NLPGGROUP BY FACT_MOSAIC_NLPG.[Output Area (Pc)], [Mosaic UK Type (Pc)]) AS FullTotalsON FullTotals.[Output Area (Pc)] = DIM_OUTPUT_AREA.OA_CODEGroup By OA_CODE, FullTotals.[Mosaic UK Type (Pc)]ORDER BY OA_CODE ASC
It returns ALL the codes associated with that output area instead of just the top one.How do I make it return just the dominant type, output area code and the total for the highest count of ID's?Cheers for any help.Spindles