Since I started working over T SQL I have faces many issues in query and resolved them by walking through blogs, however; one thing that I always thought about, was the reasons behind those issues.
One of those issues is that we can't use column alias in where clause, for instance:
SELECT SUM(CoustmerId) AS OrderCount ... WHERE OrderCount > 2000
We can't do this because in the execution order of an SQL statement SELECT clause executes after WHERE clause.
I thought that was the issue with T SQL compiler, however; later I figured out that the issue is not because of T SQL compiler but because of my lack of knowledge.
I hope this post will help people. Have a nice day.
One of those issues is that we can't use column alias in where clause, for instance:
SELECT SUM(CoustmerId) AS OrderCount ... WHERE OrderCount > 2000
We can't do this because in the execution order of an SQL statement SELECT clause executes after WHERE clause.
I thought that was the issue with T SQL compiler, however; later I figured out that the issue is not because of T SQL compiler but because of my lack of knowledge.
I hope this post will help people. Have a nice day.
No comments:
Post a Comment