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不能这样用吗?

解决方案 »

  1.   

    select * from (select 购物人,count(购物名称) as sp from sales where 数量<>0 group by 购物人) new_sales where sp>2
      

  2.   

    肯定不能
    你可以这样
    select * from (select 购物人,count (购物名称) as 购物名称 from sales where 数量<>0 group by 购物人) a  where 购物名称>2
      

  3.   

    select 购物人,count (购物名称)
    from sales 
    where 数量<>0
    group by 购物人
    having count (购物名称)>2 
     这样结果是一样的
      

  4.   

    子查询中不能用into来建表?》
      

  5.   

    子查询不能使用 Order By/Compute/Into 子句。
    除非同时指定了 Top,否则 Order By 子句在子查询中无效。