How to create VIEW with order by clause

Posted by Jeetmcts under Sql Server on 10/2/2011 | Points: 10 | Views : 3068 | Status : [Member] | Replies : 2
Can we create view with order by clause in SQL Server? or any method is available to create VIEW with order by clause.
Is possible or not to create VIEW with order by clause in Oracle also?

Jitendra Kumar


Responses

Posted by: SheoNarayan on: 10/2/2011 [Administrator] HonoraryPlatinum | Points: 25

Up
0
Down
Not sure about Oracle but I hope that SQL works similarly for SQL Server, Oracle or any other database.

View is nothing but a SQL Statement so you can create view with order by clause also. You can see below example.

CREATE VIEW [dbo].[test]

AS
SELECT TOP (100) PERCENT ParentId, AutoId, CatName
FROM dbo.Category
ORDER BY CatName


Hope this works !

Thanks

Regards,
Sheo Narayan
http://www.dotnetfunda.com

Jeetmcts, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 10/27/2011 [Member] Starter | Points: 25

Up
0
Down
View is nothing but Imaginary Table..view its wont occupy any datas. yes u can create view using order by clause..

create view emp_view
as
select empid from employee where empid not in(select * from employee
Group by empid having count(*)>1) order by empid

hope this will help ..
let me know any Questions

Regards
Sriram.R

sriram

Jeetmcts, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response