SELECT
t2.req_code_erp AS 请购单编号,
t2.req_rowno_erp AS 请购单行号,
t1.bill_code AS 询价单编号,
date( t1.ts ) AS 询价日期,
t1.corp_sub_account_name AS 采购员,
t1.supervise_psn_name AS 监督人,
t1.puorg_doc_name AS 采购组织,
t2.req_org_name AS 需求组织,
date( t01.ts ) AS 定标时间,
t01.total_amount AS 定标总金额,
t3.sup_enterprise_name AS 供应商,
t3.quota_num AS 定标数量,
t3.quota_price AS 定标单价,
t3.quota_money AS 定标金额,
t02.billno AS 合同编号,
date( t02.ts ) AS 合同生成时间,
t02.erp_ct_code AS NC合同编号,
t4.material_name AS 物料名称,
t4.num AS 合同数量,
t4.price AS 合同单价,
t4.money AS 合同未税金额,
t4.tax_money AS 合同含税金额
FROM
cpu_buyoffer.ipu_quotation t1
LEFT OUTER JOIN cpu_pricedecision.cpu_pricedecision t01 ON t1.id = t01.buyofferid
LEFT OUTER JOIN cpu_contract.cpu_ct t02 ON t1.id = t02.buyoffer_id,
cpu_buyoffer.ipu_quotation_detail t2,
cpu_pricedecision.cpu_pricedecision_detail t3,
cpu_contract.cpu_ct_material t4
WHERE
t1.id = t2.quotationid
AND t1.dr = '0'
AND t2.dr = '0'
AND t2.product_id = t3.material_id
AND t2.product_id = t4.material_id
${if(len(创建日期)>0&&len(结束日期)>0," and t1.createtime BETWEEN '"+创建日期+"' AND '"+结束日期+"'","")}
${if(len(采购组织)>0," AND t1.puorg_doc_name = '"+采购组织+"'","")}
${if(len(请购单编号)>0,"AND t2.req_code_erp = '"+请购单编号+"'","")}
Scyalcire(提问者) 回复 shirokoselect t2.req_code_erp as 请购单编号,t2.req_rowno_erp as 请购单行号,t1.bill_code as 询价单编号,date(t1.ts) as 询价日期,
t1.corp_sub_account_name as 采购员,t1.supervise_psn_name as 监督人,t1.puorg_doc_name as 采购组织,
t2.req_org_name as 需求组织,date(t01.ts) as 定标时间,t01.total_amount as 定标总金额,
t3.sup_enterprise_name as 供应商,t3.quota_num as 定标数量,t3.quota_price as 定标单价,t3.quota_money as 定标金额,
t02.billno as 合同编号,date(t02.ts) as 合同生成时间,t02.erp_ct_code as NC合同编号,
t4.material_name AS 物料名称,t4.num as 合同数量,t4.price as 合同单价,t4.money as 合同未税金额,t4.tax_money as 合同含税金额
from cpu_buyoffer.ipu_quotation t1
LEFT OUTER JOIN cpu_pricedecision.cpu_pricedecision t01 on t1.id=t01.buyofferid
LEFT OUTER JOIN cpu_contract.cpu_ct t02 on t1.id=t02.buyoffer_id,
cpu_buyoffer.ipu_quotation_detail t2,cpu_pricedecision.cpu_pricedecision_detail t3,
cpu_contract.cpu_ct_material t4
where t1.id=t2.quotationid and t1.dr=\'0\' and t2.dr=\'0\' AND
t2.product_id=t3.material_id and t2.product_id=t4.material_id and t1.createtime between \'${创建日期}\' and \'${创建日期}\' and t1.puorg_doc_name =\'${采购组织}\'and t2.req_code_erp=\'${请购单编号}\'
我想把其中的部分字段作为查询条件,但不是每个查询条件都有值才可以查