问个高手,case when中第8行=号处有错误,
写了个存储过程,想按条件来形成where条件,但是,在case when中有错误,高手们看看
CREATE proc sp_T_Message_mailcount_w
@id varchar(50)
as
begin
SELECT *,(select count(id) from dbo.T_message_q where acceptPersonID=@id and flag='0' and mailtype=a.id)as newMsg ,
(select count(id) from dbo.T_message_q where case when a.id='7' then (mailType=a.id) ELSE (acceptPersonID=@id ) AND (mailType=a.id) OR (sendPersonID=@id ) and (mailTypeSend=a.id) end) as countMsg
FROM T_message_type a
WHERE (typeuser = @id ) OR
(typeuser = '0') AND (inde <> 'CDS')
ORDER BY id
end
GO