sql keyword execution order

select m.* from(select t.*,rownum r from
(select id,name,e.username,e.realname from departments d ,employees e where d.manager=e.username(+)
order by id desc ) t where rownum<=? ) m where r>?


select m.*(select t.*,t.rownum r from(
select a,b,c,d from table1 order by a desc
) t where rownum < = ? ) m
where r > ?

The parsing order of standard SQL is:
  (1).FROM clause, assemble data from different data sources
  (2).WHERE clause, filter records based on specified conditions
  (3).GROUP BY clause, combine data Divide into multiple groups
  (4). Use aggregate functions to calculate
  (5). Use HAVING clause to filter groups
  (6). Calculate all expressions
  (7). Use ORDER BY to sort the result set
  Example: In Student In the score table (tb_Grade temporarily), group the records whose "examinee name" is not empty according to "examinee name", and filter the grouping results, and select the "total score" greater than 600 points. The
  standard SQL statement is: :
  select candidate name, max(total grade) as max total grade
  from tb_Grade
  where candidate name is not null
  group by candidate name
  having max(total grade) > 600
  order by max total grade
  In the above example, the execution order of the SQL statement is as follows :
  (1). First execute the FROM clause, assemble the data of the data source from the tb_Grade table
  (2). Execute the WHERE clause, filter all the data that are not NULL in the tb_Grade table
  (3). Execute the GROUP BY clause, put tb_Grade table by "student name"column to group
  (4). Calculate the max() aggregate function, and find the largest values ​​in the total score according to the "total score"
  (5). Execute the HAVING clause, filter the total score of the course is greater than 600 points.
  (7). Execute ORDER BY clause, sort the final results by "Max Grade".

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326129118&siteId=291194637