USE [Credit];
GO

-- Pre SQL Server 2012 behavior
SET STATISTICS IO ON;

SELECT 	SUM([charge_amt]) AS [Total_Charge_Amts],
		COUNT(DISTINCT [charge_amt]) AS [Distinct_Categories]
FROM    dbo.[charge] AS c
OPTION (RECOMPILE, QUERYRULEOFF ReduceForDistinctAggs);

SET STATISTICS IO OFF;
GO

-- 2012 behavior
SET STATISTICS IO ON;

SELECT 	SUM([charge_amt]) AS [Total_Charge_Amts],
		COUNT(DISTINCT [charge_amt]) AS [Distinct_Categories]
FROM    dbo.[charge] AS c
OPTION (RECOMPILE);

SET STATISTICS IO OFF;
GO

-- 2012 behavior, multiple DISTINCT aggs
SET STATISTICS IO ON;

SELECT 	SUM([charge_amt]) AS [Total_Charge_Amts],
		COUNT(DISTINCT [charge_amt]) AS [Distinct_Categories],
		COUNT(DISTINCT [statement_no]) AS [Distinct_Statement_No]
FROM    dbo.[charge] AS c
OPTION (RECOMPILE);

SET STATISTICS IO OFF;
GO