Technical Article

Distinct with Aggregate Function

,

Running the script you will see the different results, because we use the DISTINCT clause inside the aggregate function SUM and it is allowed!

USE ADVENTUREWORKS;
GO

SELECT SUM(DISTINCT(TAXRATE)) TAXRATES
FROM Sales.SalesTaxRate;
GO 

SELECT SUM(TAXRATE) TAXRATES
FROM Sales.SalesTaxRate;
GO

Rate

5 (1)

You rated this post out of 5. Change rating

Share

Share

Rate

5 (1)

You rated this post out of 5. Change rating