select [1]=sum(case layer when 1 then 1 end) [2]=sum(case layer when 2 then 1 end) from post提示操作符丢失,怎么回事啊。 楼上这为大哥
sorry,没有加','select [1]=sum(case layer when 1 then 1 end) ,[2]=sum(case layer when 2 then 1 end) from tablename
select [1]=sum(case layer when 1 then 1 end) ,[2]=sum(case layer when 2 then 1 end) from post怎么还是这样? 弹出对话框说 语法错误 (操作符丢失) 在查询表达式 '[1]=sum(case layer when 1 then 1 end)' 中 然后光标选中layer
检查输入的语句、标符 -------------------------------完整举例create table test (A int,B int) insert into test select 1,33 union all select 2,334 union all select 1,44 union all select 1,446 union all select 2,56 go select [1]=sum(case A when 1 then 1 end) ,[2]=sum(case A when 2 then 1 end) from test
select layer,sum(case layer when 1 then 1 end) as One, sum(case layer when 2 then 1 end) as Two from post group by layer select layer from post group by layer 我想這樣應該可以吧﹗﹗
不好意思剛想出來。上面那個不太好。 select layer,sum(case layer when 1 then 1 when 2 then 1 end) as [Count] from post group by layer 這個一定可以了。行的﹗﹗
[2]=sum(case layer when 2 then 1 end)
from post提示操作符丢失,怎么回事啊。 楼上这为大哥
,[2]=sum(case layer when 2 then 1 end)
from tablename
,[2]=sum(case layer when 2 then 1 end)
from post怎么还是这样? 弹出对话框说
语法错误 (操作符丢失) 在查询表达式 '[1]=sum(case layer when 1 then 1 end)' 中
然后光标选中layer
-------------------------------完整举例create table test (A int,B int)
insert into test select 1,33 union all select 2,334
union all select 1,44
union all select 1,446
union all select 2,56
go
select [1]=sum(case A when 1 then 1 end)
,[2]=sum(case A when 2 then 1 end)
from test
sum(case layer when 2 then 1 end) as Two
from post
group by layer
select layer from post group by layer
我想這樣應該可以吧﹗﹗
select layer,sum(case layer when 1 then 1 when 2 then 1 end) as [Count]
from post
group by layer
這個一定可以了。行的﹗﹗