In this blog , we shall teach how a SQL Processes the select statement . Processing SQL Statement means here how SQL sees , perceives and processes and gives the final result of SQL select Statement .
For Example :
=================================================
SELECT studentid, Firstname, Lastname,count(*) as Total
FROM dbo.Student
WHERE Studentid = 10
GROUP BY studentid, Firstname, Lastname
HAVING COUNT(*) > 1
ORDER BY studentid
===============================================
Now note the order of how the Select statements are actually processed IN SQL :
1. FROM
2. WHERE
3. GROUP BY
4. HAVING
5. SELECT
6. ORDER BY
Explanation:
1. Get the rows from the table
2. Chooses only those rows where the studentID is 10
3. Groups the records by studentid, Firstname, Lastname
4. It groups studentid, Firstname, Lastname Having more than one record
5. Select returns for the grouped rows
6. Orders sorts the rows in the output by studentid