top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to use ORDER BY in VIEWS

+1 vote
253 views
How to use ORDER BY in VIEWS
posted Jun 12, 2015 by Shivaranjini

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

0 votes
Create View vClientMaster
As
Select TOP 100 PERCENT ClientID, ClientName FROM ClientMaster Order BY ClientID  DESC 

But in the above example, the SQL server will not consider the [TOP 100 PERCENT] statement when executing the query. So we will not get the result in the order described in the view. But if we specify any number less than 100 PERCENT, SQL server will sort the result.
Note: It is not advisable to use ORDER BY in VIEWS. Use order by outside the view like the following:

Select ClientID, ClientName FROM vClientMaster Order BY ClientID  DESC 
answer Jun 12, 2015 by Manikandan J
...