select LinkID,C.Class,sum(case when C.Speed>20 and C.Speed<=35 then 1 else 0 end) as 出现次数,count(1) as 总现次数,sum(case when C.Speed>20 and C.Speed<=35 then 1 else 0 end)*100/(count(1)) as 百分比 into gaofengtem_table_n1 from (select A.LinkID,A.Speed,A.time,B.Class from link15m20100906 A right join Linkthree B on A.LinkID=B.LinkID) C where C.Class=1 and C.time between '2010-9-06 17:00:00.000' and '2010-9-06 18:45:00.000' Group by LinkID,Classselect * from gaofengtem_table_n1 where 百分比>=50
其实吧,我就是菜鸟,我就想第一句SQL找出来的东西,into成一个新的表,然后呢,另外一个按钮,就负责select这个表我想把这两者接起来,不用生成什么gaofengtem_table_n1 这个表了,直接select 出来请教高手咋做
其实吧,我就是菜鸟,我就想第一句SQL找出来的东西,into成一个新的表,然后呢,另外一个按钮,就负责select这个表我想把这两者接起来,不用生成什么gaofengtem_table_n1 这个表了,直接select 出来请教高手咋做
sum(case when C.Speed>20 and C.Speed<=35 then 1 else 0 end) as 出现次数,
count(1) as 总现次数,
sum(case when C.Speed>20 and C.Speed<=35 then 1 else 0 end)*100/(count(1)) as 百分比
from (
select A.LinkID,A.Speed,A.time,B.Class
from link15m20100906 A right join Linkthree B on A.LinkID=B.LinkID) C where C.Class=1 and C.time
between '2010-9-06 17:00:00.000' and '2010-9-06 18:45:00.000' Group by LinkID,Class
having sum(case when C.Speed>20 and C.Speed<=35 then 1 else 0 end)*100/(count(1)) >=50
having sum(case when C.Speed>20 and C.Speed<=35 then 1 else 0 end)*100/(count(1))>=50
*
from
(select LinkID,C.Class,sum(case when C.Speed>20 and C.Speed<=35 then 1 else 0 end) as 出现次数,count(1) as 总现次数,sum(case when C.Speed>20 and C.Speed<=35 then 1 else 0 end)*100/(count(1)) as 百分比 into gaofengtem_table_n1 from (select A.LinkID,A.Speed,A.time,B.Class from link15m20100906 A right join Linkthree B on A.LinkID=B.LinkID) C where C.Class=1 and C.time between '2010-9-06 17:00:00.000' and '2010-9-06 18:45:00.000' Group by LinkID,Class
)t where 百分比>=50