以系统中的供应商基础资料为例,因为此基础资料是分配型的,所以在开发相关的简单账表和其他类型账表的时候,要注意拼接条件的不同;


select t1.fdate Fdate,FPURCHASEORGID,

FREALQTY Fqty,t3.FAPJOINAMOUNT/t2.FREALQTY Fprice,t3.FAPJOINAMOUNT Famount,FMATERIALID,t4.fmasterid FSUPPLIERID,FSTOCKID,FSTOCKDEPTID,t1.FDOCUMENTSTATUS

from (select fbillno,fdate,FSUPPLIERID,FSTOCKDEPTID,fid,FPURCHASEORGID,FDOCUMENTSTATUS,FSTOCKORGID from T_STK_INSTOCK where fid>1) t1

inner join (select FSTOCKID,fid,FREALQTY,FMATERIALID,FENTRYID from T_STK_INSTOCKentry where FENTRYID>1) t2 on t1.fid=t2.fid

inner join (select FENTRYID,FAPJOINAMOUNT from T_STK_INSTOCKENTRY_F where FENTRYID>1) t3 on t2.FENTRYID=t3.FENTRYID

inner join t_bd_supplier t4 on t1.FSUPPLIERID =t4.FSUPPLIERID and t1.FSTOCKORGID=FUSEORGID

where 1=1 {0}


注:入库单中的供应商字段后台存的id是与供应商基础资料的FSUPPLIERID相对应(t1.FSUPPLIERID =t4.FSUPPLIERID),但是如果过滤框中如果使用了供应商条件的话,它传到临时表中的id是fmasterid,所以要转换下!