SQL statement execution sequence
The following figure shows the execution sequence of SQL statements:
(This figure is from the SQL statement execution Sequence Graph)
This picture clearly shows the execution sequence of SQL statements. Today, we have made a question and deepened our understanding of the execution sequence of SQL statements.
There is a table like this:
Question:
Lists the product ids (PRODUCT id: PRODUCT $ id) and quantity of all products contained in more than one order (Order Number: XORDER $ id) in descending order of the PRODUCT id.
The SQL statement is as follows:
Select PRODUCT $ ID, sum (quantity) from LINEITEM group by PRODUCT $ ID having count (PRODUCT $ ID)> 1 order by PRODUCT $ ID desc;
The result is as follows:
Although the where clause is missing in this example, it does not affect the execution process of SQL statements, because the where clause is so common that we have long understood it.