存储过程过滤

时间:2013-09-16 07:37:01

标签: sql sql-server stored-procedures

有我计算提供商阶段付款的程序,阶段6有3个提供商让我们打电话 A,B,C 我想要计数*阶段付款但在第6阶段我不想要计数B(id = 101)提供者付款,我写选择:

select phase , count(*) as countPhases
from  dbo.auth a
inner join dbo.providers p ON a.provider_id = p.serno 
where (date between @from_date and @to_date) and (provider_id <> 101 and phase <> 6 )
group by phase

但它不会过滤我想要的方式(provider_id&lt;&gt; 101和阶段&lt;&gt; 6),请帮帮我

1 个答案:

答案 0 :(得分:1)

试试这个

where (date between @from_date and @to_date)
      and (phase <> 6
           or (phase=6 and provider_id <> 101))