
[统计明细表2]
DATASET_COUNT=2
DS_ALIAS1=SF
DS_ALIAS2=SF2
SQL1=select Yw_Type,sum(Sfje) as je from V_CATV_YW_SFRECORD group by Yw_Type
SQL2=select yhlb,sum(Sfje) as je from V_CATV_YW_SFRECORD group by yhlb
(select 1 as n, In_AutoNum,sh_date,ClientName,PayType,TIn_Num as Sl,TIn_Price as Cb from  V_Pj_InHead where In_Date between #D_B# and #D_E# and InFlag=2) union all (select 2 as n,'合计' as In_AutoNum,'---' as sh_date,'---' as ClientName,'---' as PayType,sum(TIn_Num) as Sl,sum(TIn_Price) as Cb from  V_Pj_InHead where In_Date between #D_B# and #D_E# and InFlag=2)

[工资情况统计表]
DATASET_COUNT=1
DS_ALIAS1=GZ
SQL1=(select 1 as n,ZgName,Work_Date,sum(Jbgz) as Jbgz,sum(Tcgz) as Tcgz,sum(TGz_Hr) as TGz_Hr,sum(TGz_Jj) as TGz_Jj,sum(TGz_Total) as TGz_Total from V_Yw_Wages where UseSate=1 and Work_Date between #D_B# and #D_E# QT_TJ group by ZgName,Work_Date)union all(select 2 as n,'合计' as ZgName,'---' as Work_Date,sum(Jbgz) as Jbgz,sum(Tcgz) as Tcgz,sum(TGz_Hr) as TGz_Hr,sum(TGz_Jj) as TGz_Jj,sum(TGz_Total) as TGz_Total from V_Yw_Wages  where UseSate=1 and Work_Date between #D_B# and #D_E# QT_TJ)

[销售情况统计表]
DATASET_COUNT=2
DS_ALIAS1=M
DS_ALIAS2=D
SQL1=(select 1 as n, GoodsNo,GoodsName,GoodsName_E,Depart, sum(SaNum) as TSaNum,sum(TSs_Price) as TSa_Price from V_Yw_SaDetail_Ser where Send_Date between #D_B# and #D_E# QT_TJ group by GoodsNo,GoodsName,GoodsName_E,Depart)union all (select 2 as n,'合计' as GoodsNo,'---' as GoodsName,'---' as GoodsName_E,'---' as Depart, sum(SaNum) as TSaNum,sum(TSs_Price) as TSa_Price from V_Yw_SaDetail_Ser where Send_Date between #D_B# and #D_E# QT_TJ )
SQL2=select count(*) as YwNum,sum(TSsPrice) as TSsPrice,sum(TNum) as TNum,round(sum(TSsPrice)/count(*)*100)/100 as  AvgPrice,round(sum(TNum)/count(*)*100)/100 as AvgNum from V_Yw_SaHead where Send_Date between #D_B# and #D_E#

[原料进货情况统计表]
DATASET_COUNT=2
DS_ALIAS1=M
DS_ALIAS2=D
SQL1=(select 1 as n, GoodsNo,GoodsName,GoodsName_E,Depart, sum(InNum) as TInNum,sum(TIn_Price) as TIn_Price from V_Yw_InDetail_Ser where Yw_Type=0 and  In_Date between #D_B# and #D_E# QT_TJ group by GoodsNo,GoodsName,GoodsName_E,Depart)union all (select 2 as n,'合计' as GoodsNo,'---' as GoodsName,'---' as GoodsName_E,'---' as Depart, sum(InNum) as TInNum,sum(TIn_Price) as TIn_Price from V_Yw_InDetail_Ser where Yw_Type=0 and In_Date between #D_B# and #D_E# QT_TJ )
SQL2=select count(*) as YwNum,sum(TPrice) as TPrice,sum(TNum) as TNum,round(sum(TPrice)/count(*)*100)/100 as  AvgPrice,round(sum(TNum)/count(*)*100)/100 as AvgNum from V_Yw_InHead where Yw_Type=0 and In_Date between #D_B# and #D_E#

[代理产品进货情况表]
DATASET_COUNT=2
DS_ALIAS1=M
DS_ALIAS2=D
SQL1=(select 1 as n, GoodsNo,GoodsName,GoodsName_E,Depart, sum(InNum) as TInNum,sum(TIn_Price) as TIn_Price from V_Yw_InDetail_Ser where Yw_Type=2 and  In_Date between #D_B# and #D_E# QT_TJ group by GoodsNo,GoodsName,GoodsName_E,Depart)union all (select 2 as n,'合计' as GoodsNo,'---' as GoodsName,'---' as GoodsName_E,'---' as Depart, sum(InNum) as TInNum,sum(TIn_Price) as TIn_Price from V_Yw_InDetail_Ser where Yw_Type=2 and In_Date between #D_B# and #D_E# QT_TJ )
SQL2=select count(*) as YwNum,sum(TPrice) as TPrice,sum(TNum) as TNum,round(sum(TPrice)/count(*)*100)/100 as  AvgPrice,round(sum(TNum)/count(*)*100)/100 as AvgNum from V_Yw_InHead where Yw_Type=2 and In_Date between #D_B# and #D_E#

[生产情况统计表]
DATASET_COUNT=1
DS_ALIAS1=M
SQL1=(select 1 as n, GoodsNo,GoodsName,GoodsName_E,Depart, count(*) as TCs,sum(InNum) as TInNum,sum(InNum_Unit2) as TInNum_Unit2 from V_Yw_InDetail_Sc_Ser where Yw_Type=1 and In_Date between #D_B# and #D_E# QT_TJ group by GoodsNo,GoodsName,GoodsName_E,Depart)union all (select 2 as n,'合计' as GoodsNo,'---' as GoodsName,'---' as GoodsName_E,'---' as Depart,  count(*) as TCs,sum(InNum) as TInNum,sum(InNum_Unit2) as TInNum_Unit2 from V_Yw_InDetail_Sc_Ser where Yw_Type=1 and In_Date between #D_B# and #D_E# QT_TJ )

[原料消耗情况统计表]
DATASET_COUNT=1
DS_ALIAS1=M
SQL1=(select 1 as n, GoodsNo,GoodsName,GoodsName_E,Depart, sum(UseNum) as TUseNum,sum(UseNum_Unit2) as TUseNum_Unit2 from V_Yw_Sc_UseYlDetail where In_Date between #D_B# and #D_E# QT_TJ group by GoodsNo,GoodsName,GoodsName_E,Depart)union all (select 2 as n,'合计' as GoodsNo,'---' as GoodsName,'---' as GoodsName_E,'---' as Depart,  sum(UseNum) as TUseNum,sum(UseNum_Unit2) as TUseNum_Unit2 from V_Yw_Sc_UseYlDetail where In_Date between #D_B# and #D_E# QT_TJ )


[]
select count(*) as YwNum,sum(TSsPrice) as TSsPrice,sum(TNum) as TNum from V_Yw_SaHead

(select 1 as n,ZgName,Work_Date,sum(Jbgz) as Jbgz,sum(Tcgz) as Tcgz,sum(TGz_Hr) as TGz_Hr,sum(TGz_Jj) as TGz_Jj,sum(TGz_Total) as TGz_Total from V_Yw_Wages  where Work_Date between #D_B# and #D_E# QT_TJ group by ZgName,Work_Date)union all(select 2 as n,'合计' as ZgName,'---' as Work_Date,sum(Jbgz) as Jbgz,sum(Tcgz) as Tcgz,sum(TGz_Hr) as TGz_Hr,sum(TGz_Jj) as TGz_Jj,sum(TGz_Total) as TGz_Total from V_Yw_Wages  where Work_Date between #D_B# and #D_E# QT_TJ)

[ERRORSQL]
SQL=(select 1 as n,ZgName,Work_Date,sum(Jbgz) as Jbgz,sum(Tcgz) as Tcgz,sum(TGz_Hr) as TGz_Hr,sum(TGz_Jj) as TGz_Jj,sum(TGz_Total) as TGz_Total from V_Yw_Wages where UseSate=1 and Work_Date between #2010-10-18# and #2010-10-18#  group by ZgName,Work_Date)union all(select 2 as n,'合计' as ZgName,'---' as Work_Date,sum(Jbgz) as Jbgz,sum(Tcgz) as Tcgz,sum(TGz_Hr) as TGz_Hr,sum(TGz_Jj) as TGz_Jj,sum(TGz_Total) as TGz_Total from V_Yw_Wages  where UseSate=1 and Work_Date between #2010-10-18# and #2010-10-18# )

