34,571
社区成员
发帖
与我相关
我的任务
分享
create table hhh1(id int,col varchar(20))
--这样创建视图无效
create view hhh1view
as
select * from hhh1 order by col
/*
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
*/
--这种创建就可以了
create view hhh1view
as
select * from hhh1
select * from hhh1view order by col
select a,b,c From (
SELECT 1 as px,a,b,c
FROM tb
WHERE DATEDIFF(day, b ,getdate())>=3
union all
SELECT 2 as px,a,b,c
FROM tb
WHERE DATEDIFF(day, b ,getdate())<3
) t
order by
px,
case when px=1 then -b else b end
select * from yourviewname order by b
top 100 PERCENT...