Click here to Skip to main content
15,305,361 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Order of execution of query in sql is follow according to my knowledge.

1. FROM
2. ON
3. OUTER/Inner
4. WHERE
5. GROUP BY
6. CUBE or ROLLUP
7. HAVING
8. SELECT
9. DISTINCT
10. ORDER BY
11. TOP
Can anybody tell me order of execution of aggregate function.In my select clause I have 2 aggregate function.Which one get executed first?

SQL
Select City, Gender, SUM(Salary) as TotalSalary,
COUNT(ID) as TotalEmployees
from tblEmployee
group by City, Gender
Posted
Updated 4-Nov-15 1:56am
v2

1 solution

Time for you to read some documentation.
https://msdn.microsoft.com/en-us/library/ms189499.aspx[^]
   
Comments
jaket-cp 4-Nov-15 8:31am
   
Can you specify where in the documentation you are referring, to answer this question.
Thanks
John C Rayan 4-Nov-15 8:57am
   
Hi

Despite the fact that it does not directly answer your question , Group By will give you pointer to answering to your question. Also the overall logical processing of the article would help you understand more about your answer.
jaket-cp 4-Nov-15 8:59am
   
Thanks for the reply - this is not my question.
I was just interested in what the solution could be, but reading the document you pointed to did not answer it for me.
John C Rayan 4-Nov-15 9:04am
   
Could I ask you the reason for knowing the order of the aggregate functions? If you tell use what you are trying to do then it will help us to give you the solution. There is an answer for the same question in this link

http://stackoverflow.com/questions/33521657/execution-order-of-aggregate-function-in-sql
jaket-cp 4-Nov-15 9:07am
   
As I said I am not the OP.
Was just interested to know the solution to the question of the OP, that is all.
Thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900