开发者

What is the correct order of these clauses while writing a SQL query?

开发者 https://www.devze.com 2023-02-04 14:33 出处:网络
There are many clauses in SQL Server such as SELECT, 开发者_Go百科WHERE, GROUP BY, ORDER BY, HAVING

There are many clauses in SQL Server such as SELECT, 开发者_Go百科WHERE, GROUP BY, ORDER BY, HAVING

What is the correct order of these clauses while writing a query?


http://msdn.microsoft.com/en-us/library/ms189499.aspx

[ WITH <common_table_expression>]

SELECT select_list [ INTO new_table ]

[ FROM table_source ] [ WHERE search_condition ]

[ GROUP BY group_by_expression ]

[ HAVING search_condition ]

[ ORDER BY order_expression [ ASC | DESC ] ]


SELECT
Groupby
Having
OrderBy

Or

SELECT
WHERE
OrderBy


This is just a very generic query. You will need to start reading basics of SQL first. Check the link below first -

http://www.sql-tutorial.net/

0

精彩评论

暂无评论...
验证码 换一张
取 消