select 购物人,count(购物名称) as sp into new_sales from sales where 数量<>0 group by 购物人
select * from new_sales where sp>2
这条语句是可以实现的
select * from (select 购物人,count(购物名称) into new_sales from sales where 数量<>0 group by 购物人) where count(购物名称)>2
这条语句在运行的时候提示into附近有错误请问into不能这样用吗?
select * from new_sales where sp>2
这条语句是可以实现的
select * from (select 购物人,count(购物名称) into new_sales from sales where 数量<>0 group by 购物人) where count(购物名称)>2
这条语句在运行的时候提示into附近有错误请问into不能这样用吗?
你可以这样
select * from (select 购物人,count (购物名称) as 购物名称 from sales where 数量<>0 group by 购物人) a where 购物名称>2
from sales
where 数量<>0
group by 购物人
having count (购物名称)>2
这样结果是一样的
除非同时指定了 Top,否则 Order By 子句在子查询中无效。