create proc hotdata
as
begin
select * from tb_detail where MM_Id in
(  
  select MM_Id from
  (
     select MM_Id count(*) as num from tb_detail
     group by MM_Id
     order by num
   )
)
endsql分析语法说end上面的一个括号“)”附近有语法错误,求解,谢谢!!

解决方案 »

  1.   

    create proc hotdata 
    as 
    begin 
    select * from tb_detail where MM_Id in 
    (  
      select MM_Id from 
      ( 
        select MM_Id count(*) as num from tb_detail 
        group by MM_Id 
        order by num 
      ) AS T
    ) AS T1
    end 其他的不修改,别名还是要加
      

  2.   

    有两处错误:
    1、中间的
    select MM_Id count(*) as num from tb_detail 
    应该是
    select MM_Id ,count(*) as num from tb_detail 2、缺少别名create proc hotdata 
    as 
    begin 
    select * from tb_detail where MM_Id in 
    (  
      select MM_Id from 
      ( 
        select MM_Id ,count(*) as num from tb_detail 
        group by MM_Id 
        order by num 
      ) aa

    end