In MSSql,"Order by" and "distinct" can be used in view?
thanks!u can use 'order by' and 'distinct' in view.u have to use 'top ' key word when use order by clause.See below example,
use pubs
go
create view vauthors
as
select distinct top 100 percent city from authors
order by city|||No. It does not make sense to do order by in the view as a view is just a partion of a table(s). Perform the ordering you required when you select from the view.
Select *
from YourView
Order By your_view_column|||I remember that the following SQL is wrong:
create view vauthors
as
select distinct top 100 percent city from authors
order by city
Now in MSSQL,it can be run?
it mustn't include the order by and distinct in view,now it can be?|||what khtan said is right. u should order by when u select from view.though it is possible that 'order by' clause can be used in view,which u asked
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment