473,387 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

What is the sequence of execution of an SQL select query in SQL Server

theGeek
11
Hi All!!

Please look at the query below:

Expand|Select|Wrap|Line Numbers
  1.  
  2. select 
  3.         * 
  4. from 
  5.         tab1 inner join
  6.         tab2 on tab1.c1 = tab2.c1 inner join
  7.         tab3 on tab1.c2 = tab3.c2
  8. where
  9.         tab1.c1 = some_value and
  10.         tab2.c1 in 
  11.              (select c1 from tab4)
  12. group by
  13.         tab1.c2
  14. having
  15.         tab1.c1 = some_value
  16. order by
  17.         tab1.c1 asc
  18.  
That is a usual sql query that one would write to do something though all of the clauses may not be needed depending upon the requirement.

I wnated to know the sequence in which various clauses in a select query are executed so that I can write correct & better queries. I even googled and found the answer to some extent but not satisfied. The search let me know the following sequence:
1> from
2> where
3> group by
4> having
5> order by

Apparantely there can be more clauses as well as subqueries as in above sample query. Can somebody help me with this?!?!?

Thanks!!
Dec 18 '07 #1
0 3611

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: anita hery | last post by:
Hi All I found an error ( run time error 3669. Execution cancelled) when ran the following query via VB6 SP5. select crc,month,sum(v) as v from ( select crc,v, case when fadate between...
4
by: M Wells | last post by:
Hi All, I have a table that currently contains approx. 8 million records. I'm running a SELECT query against this table that in some circumstances is either very quick (ie results returned in...
1
by: Robin Hammond | last post by:
Can anybody tell me why a) when running a stored proc from an asp page to return a recordset the command succeeds if the sp queries an existing table directly, but b) if the stored proc populates...
6
by: Christine Wolak | last post by:
I'm looking for assistance on a problem with SQL Server. We have a database where a particular query returns about 3000 rows. This query takes about 2 minutes on most machines, which is fine in...
5
by: Glenn | last post by:
Hi! Server info - Win2K3 Server +SP1 with 1 GB Memory and 1.5 GB Virtual Memory SQL Server 2000 Enterprise Edition + SP3 running on this. Required result - Create a SQL Script that will...
5
by: mas | last post by:
I have a Stored Procedure (SP) that creates the data required for a report that I show on a web page. The SP does all the work and just returns back a results set that I dump in an ASP.NET...
17
by: vishal | last post by:
I am new to sql and require some help on cursors? what are they and how and why are they used for??? it will be kind enough if anyone helps me in this regards.. regards vishal jain.
17
by: Grizlyk | last post by:
Hello. What can be optimised in C++ code and how i can garantee stable behaviour below 1. Are expression "auto volatile" can deny removing as "unused temporary" like this: auto volatile...
4
by: raylopez99 | last post by:
I'm reading a book that talks about how some operations, like LINQ queries, are "deferred execution" while other queries are "immediate execution". What is the difference? RL
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.