SUM() takes less time than SELECT() in SQL. How it works?

Viewed 1547

I have a SQL table containing 1 million records. When I call

SELECT *
   FROM [AdventureWorksDW2012].[dbo].[LotTable]

it took 13 seconds to complete the query.

I ran the below query to get the SUM() of ID column. It contains random numbers containing plus and minus values.

 SELECT SUM(NewestID)
   FROM LotTable

This query just took 500 Milliseconds. To execute SUM() SQL engine should read the values and apply some operation on it. But how it is running quickly than SELECT(). What is the logic behind? Refer the below images.Thanks in advance.

SELECT()SUM()

3 Answers
Related