CREATE PROCEDURE GetUserNullCount(
out o_nBase int ,
out o_detail int)
begin
select o_nBase =((case when user_ext_Mobile is null then 1 else 0 end)+
(case when user_ext_PhoneNumber is null then 1 else 0 end)+
(case when user_ext_MsnNumber is null then 1 else 0 end)+
(case when user_ext_QQNumber is null then 1 else 0 end)+
(case when user_ext_OtherLinkType is null then 1 else 0 end)),
 o_nMore =((case when user_ext_Height is null then 1 else 0 end)+
(case when user_ext_Education is null then 1 else 0 end)+
(case when user_ext_Housing is null then 1 else 0 end)+
(case when user_ext_WorkItem is null then 1 else 0 end)+
(case when user_ext_PayMonth is null then 1 else 0 end)+
(case when user_ext_userMarrige is null then 1 else 0 end)+
(case when user_ext_userChild is null then 1 else 0 end)),
from userlist where id=200
end

解决方案 »

  1.   

    CREATE PROCEDURE GetUserNullCount(
    out o_nBase int ,
    out o_detail int)
    begin
    select ((case when user_ext_Mobile is null then 1 else 0 end)+
    (case when user_ext_PhoneNumber is null then 1 else 0 end)+
    (case when user_ext_MsnNumber is null then 1 else 0 end)+
    (case when user_ext_QQNumber is null then 1 else 0 end)+
    (case when user_ext_OtherLinkType is null then 1 else 0 end)),
     o_nMore =((case when user_ext_Height is null then 1 else 0 end)+
    (case when user_ext_Education is null then 1 else 0 end)+
    (case when user_ext_Housing is null then 1 else 0 end)+
    (case when user_ext_WorkItem is null then 1 else 0 end)+
    (case when user_ext_PayMonth is null then 1 else 0 end)+
    (case when user_ext_userMarrige is null then 1 else 0 end)+
    (case when user_ext_userChild is null then 1 else 0 end)),
    from userlist where id=200
    end
    CREATE PROCEDURE GetUserNullCount(
    out o_nBase int ,
    out o_detail int)
    begin
    select o_nBase =((case when user_ext_Mobile is null then 1 else 0 end)+
    (case when user_ext_PhoneNumber is null then 1 else 0 end)+
    (case when user_ext_MsnNumber is null then 1 else 0 end)+
    (case when user_ext_QQNumber is null then 1 else 0 end)+
    (case when user_ext_OtherLinkType is null then 1 else 0 end)),
     o_nMore =((case when user_ext_Height is null then 1 else 0 end)+
    (case when user_ext_Education is null then 1 else 0 end)+
    (case when user_ext_Housing is null then 1 else 0 end)+
    (case when user_ext_WorkItem is null then 1 else 0 end)+
    (case when user_ext_PayMonth is null then 1 else 0 end)+
    (case when user_ext_userMarrige is null then 1 else 0 end)+
    (case when user_ext_userChild is null then 1 else 0 end)),
    from userlist where id=200
    endselect  
      

  2.   

    select o_nBase =((case whe改成 select o_nBase:=((case whe或者select  ((case whe ..... ) into  o_nBase, 
      

  3.   

    ============================================================================
    CREATE PROCEDURE GetUserNullCount(
    out o_nBase int ,
    out o_detail int)
    begin
    select ((case when user_ext_Mobile is null then 1 else 0 end)+
    (case when user_ext_PhoneNumber is null then 1 else 0 end)+
    (case when user_ext_MsnNumber is null then 1 else 0 end)+
    (case when user_ext_QQNumber is null then 1 else 0 end)+
    (case when user_ext_OtherLinkType is null then 1 else 0 end)) into o_Base,
     ((case when user_ext_Height is null then 1 else 0 end)+
    (case when user_ext_Education is null then 1 else 0 end)+
    (case when user_ext_Housing is null then 1 else 0 end)+
    (case when user_ext_WorkItem is null then 1 else 0 end)+
    (case when user_ext_PayMonth is null then 1 else 0 end)+
    (case when user_ext_userMarrige is null then 1 else 0 end)+
    (case when user_ext_userChild is null then 1 else 0 end)) into o_nMore,
    from userlist where id=200end
    into o_Base,前的代码可以运行,之后的代码视为语法错误 ?
      

  4.   

    ==================================================================你好,我的这个存储过程是统计某个用户的资料完成情况,这是sql server2000下的东西,我想移植到mysql上,不知道mysql统计某条记录的未填写字段有什么好办法?