SELECT * FROM TABLE WHERE 1=1 ${IF(LEN(下拉)==0,"",IF(下拉="是"," AND CSCLOSER IS NOT NULL"," and CSCLOSER IS NULL"))}
------------------
SELECT * FROM TABLE WHERE 1=1 ${switch(下拉,"是","AND CSCLOSER IS NOT NULL","否","CSCLOSER IS NULL",下拉,"")}
----------------
SELECT * FROM TABLE WHERE 1=1 ${if(len(p_sfgb)=0,""," AND (CASE WHEN ISNULL(b.cscloser,'')='' THEN 'FALSE' ELSE 'TRUE' END)='"+p_sfgb+"'" )}
---------------
终于清楚你的设置了:
1、控件值为 是/否 case的时候也应该是 是/否,不是true/false (SQL结束处)
2、你要判断的是B表的字段,所以用 LEFT join B没用,A表的数据仍然全部显示,需要改成 INNER 或者 right JOIN
select m.cjy, b.cscloser, a.cexch_name, a.csocode,a.ddate,a.ccuscode,c.ccusname,b.cinvcode,i.cinvname,i.cinvstd,com.ccomunitname,b.iquantity,b.inum,b.inatunitprice, b.inatsum,qty,b.iquantity-isnull(qty,0) wfhqty ,i.cInvStd,l.cInvcName,b.iNatMoney,b.iTaxUnitPrice,dis.iiSum,b.iTaxRate,b.iNatUnitPrice,dis.iMoney from ${p_zt}..so_somain a inner join ${p_zt}..so_sodetails b on a.id=b.id left join (select isosid,sum(iquantity) qty ,sum(iNatMoney) iMoney,sum(inatsum)iisum from ${p_zt}..dispatchlist d left join ${p_zt}..dispatchlists e on d.dlid=e.dlid where 1=1 ${if(len(p_cuscode)=0,""," and ccuscode = '"+p_cuscode+"'")} ${if(len(p_fhbegindate)=0,""," and ddate >='"+fhbegindate+"'")} ${if(len(p_fhenddate)=0,""," and ddate <='"+p_fhenddate+"'")} group by isosid ) dis on b.isosid=dis.isosid left join customer c on a.ccuscode=c.ccuscode left join inventory i on b.cinvcode=i.cinvcode left join inventoryclass l on i.cinvccode=l.cinvccode left join computationunit com on i.cpucomunitcode=com.ccomunitcode left join dm_salebillvouchs_list m on m.ccusname =c.ccusname where 1=1 ${if(len(p_cuscode)=0,""," and a.ccuscode ='"+p_cuscode+"'")} ${if(len(p_sobegindate)=0,""," and a.ddate >='"+p_sobegindate+"'")} ${if(len(p_soenddate)=0,""," and a.ddate <='"+p_soenddate+"'")} ${if(len(p_wlfl)=0,""," and l.cInvcName ='"+p_wlfl+"'")} ${if(len(p_chbm)=0,""," and b.cinvcode ='"+p_chbm+"'")} ${if(len(p_ggxh)=0,""," and i.cinvstd ='"+p_ggxh+"'")} ${if(len(p_ddh)=0,""," and a.csocode ='"+p_ddh+"'")} ${if(len(p_bz)=0,""," and a.cexch_name ='"+p_bz+"'")} ${if(len(p_jy)=0 || p_jy='是' ,"", " and isnull(m.cjy,'') ='' " )} ${if(len(p_sfgb)=0,"", " and (case when isnull(b.cscloser,'')='' then '否' else '是' end)='"+p_sfgb+"'" )}