Home > Backend Development > PHP Tutorial > Using ORDER BY clause in views_PHP Tutorial

Using ORDER BY clause in views_PHP Tutorial

WBOY
Release: 2016-07-13 17:03:38
Original
874 people have browsed it

Q: Why does SQL Server not allow the ORDER BY clause in view definitions?
Answer: The reason why SQL Server does not allow the use of the ORDER BY clause in the view definition is to comply with the ANSI SQL-92 standard. Because an analysis of the principles of the standard would require a discussion of the underlying structure of Structured Query Language (SQL) and the mathematical theory on which it is based, we cannot fully explain it here. However, if you need to specify the ORDER BY clause in the view, consider using the following method:
USE pubs
GO
CREATE VIEW AuthorsByName
AS
SELECT TOP 100 PERCENT *
FROM authors
ORDER BY au_lname, au_fname
GO
The TOP structure introduced by Microsoft in SQL Server 7.0 is very useful when used in conjunction with the ORDER BY clause. SQL Server supports the use of the ORDER BY clause in views only when used in conjunction with the TOP keyword.

Note: The TOP keyword is SQL Server’s extension to the ANSI SQL-92 standard.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/630957.htmlTechArticleQ: Why does SQL Server not allow the ORDER BY clause in view definitions? Answer: The reason why SQL Server does not allow the use of the ORDER BY clause in the view definition is to comply with the ANSI SQL-92 standard. Because...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template