首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

请教以下句子怎么改正

2012-03-09 
请问以下句子如何改正?selectitem1from(selectitem1,orderingCASEWHENitem2ISNULLTHEN1ELSE0ENDfromtable

请问以下句子如何改正?
select   item1
from  
(
select   item1,   ordering   =   CASE   WHEN   item2   IS   NULL   THEN   1   ELSE   0   END
from   tableA
order   by   ordering
)

[解决办法]
select item1
from
(
select top 100 percent item1, ordering = CASE WHEN item2 IS NULL THEN 1 ELSE 0 END
from tableA
order by ordering
)a

[解决办法]
select item1
from
(
select top 100 percent item1, ordering = CASE WHEN item2 IS NULL THEN 1 ELSE 0 END
from tableA
order by ordering
)a
[解决办法]
(
select item1, ordering = CASE WHEN item2 IS NULL THEN 1 ELSE 0 END
from tableA
Where TableB.Item3 = TableA.Item3
order by ordering
)

--内有order by ,需要在select 后面加top ,所以会报错!
正确的为:

Update TableB
Set Item1 =
(
select TOP 1 item1
from
(
select top 100 percent item1, ordering = CASE WHEN item2 IS NULL THEN 1 ELSE 0 END
from tableA
Where TableB.Item3 = TableA.Item3
order by ordering
) a
)

热点排行