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/
精彩评论