sql case statement in where clause , need to join check on different tables on different cases -
select nc.status newcustomer nc inner join #salesexec userfiltr on userfiltr.userid = nc.reportedby left join distributor d on nc.distributorid = d.distributorid left join shop s on s.shopid = nc.shopid left join shoptype st on st.shoptypeid = s.shoptypeid left join #orgshop orgfiltr on orgfiltr.organizationid = d.organizationid convert(varchar, nc.mobiletransactiondate, 101) between @fromdate , @todate , case nc.status when 1 (st.shoptype null or st.shoptype = '' or st.shoptype <> 'distributor') else (nc.shoptype null or nc.shoptype = '' or nc.shoptype <> 'distributor') end group reportedby
you may looking this
and 1 = case when nc.status = 1 , (st.shoptype null or st.shoptype ='' or st.shoptype <> 'distributor' ) 1 when (nc.shoptype null or nc.shoptype ='' or nc.shoptype<> 'distributor' ) 1 end
Comments
Post a Comment