|
|
@@ -10,7 +10,7 @@ inner join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
where t1.fstatus in('审核','关闭') and t3.fstatus='关闭' and t1.siteid=@siteid and CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,0,getdate()),120) group by t1.fagentnum,fsaler) t1
|
|
|
inner join (
|
|
|
select fagentnum,sum(t.famount) famount,fsaler from
|
|
|
-(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(t2.famount-isnull(fwriteoffamount,0),0) famount from saorder t1
|
|
|
+(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(fwriteoffamount,0) famount from saorder t1
|
|
|
inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
|
|
|
left join sainvoicedetail t4 on t4.fsourceid=t2.saorderdetailid and t4.siteid=t2.siteid
|
|
|
left join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
@@ -25,7 +25,7 @@ inner join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
where t1.fstatus in('审核','关闭') and t3.fstatus='关闭' and t1.siteid=@siteid and CONVERT(VARCHAR(10),t1.checkdate,120)>=CONVERT(VARCHAR(10),DATEADD(mm,-1,getdate()),120) and CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,0,getdate()),120) group by t1.fagentnum,fsaler) t1
|
|
|
left join (
|
|
|
select fagentnum,sum(t.famount) famount,fsaler from
|
|
|
-(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(t2.famount-isnull(fwriteoffamount,0),0) famount from saorder t1
|
|
|
+(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(fwriteoffamount,0) famount from saorder t1
|
|
|
inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
|
|
|
left join sainvoicedetail t4 on t4.fsourceid=t2.saorderdetailid and t4.siteid=t2.siteid
|
|
|
left join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
@@ -40,7 +40,7 @@ inner join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
where t1.fstatus in('审核','关闭') and t3.fstatus='关闭' and t1.siteid=@siteid and CONVERT(VARCHAR(10),t1.checkdate,120)>=CONVERT(VARCHAR(10),DATEADD(mm,-3,getdate()),120) and CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,-1,getdate()),120) group by t1.fagentnum,fsaler) t1
|
|
|
inner join (
|
|
|
select fagentnum,sum(t.famount) famount,fsaler from
|
|
|
-(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(t2.famount-isnull(fwriteoffamount,0),0) famount from saorder t1
|
|
|
+(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(fwriteoffamount,0) famount from saorder t1
|
|
|
inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
|
|
|
left join sainvoicedetail t4 on t4.fsourceid=t2.saorderdetailid and t4.siteid=t2.siteid
|
|
|
left join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
@@ -55,7 +55,7 @@ inner join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
where t1.fstatus in('审核','关闭') and t3.fstatus='关闭' and t1.siteid=@siteid and CONVERT(VARCHAR(10),t1.checkdate,120)>=CONVERT(VARCHAR(10),DATEADD(mm,-6,getdate()),120) and CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,-3,getdate()),120) group by t1.fagentnum,fsaler) t1
|
|
|
inner join (
|
|
|
select fagentnum,sum(t.famount) famount,fsaler from
|
|
|
-(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(t2.famount-isnull(fwriteoffamount,0),0) famount from saorder t1
|
|
|
+(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(fwriteoffamount,0) famount from saorder t1
|
|
|
inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
|
|
|
left join sainvoicedetail t4 on t4.fsourceid=t2.saorderdetailid and t4.siteid=t2.siteid
|
|
|
left join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
@@ -70,7 +70,7 @@ inner join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
where t1.fstatus in('审核','关闭') and t3.fstatus='关闭' and t1.siteid=@siteid and CONVERT(VARCHAR(10),t1.checkdate,120)>=CONVERT(VARCHAR(10),DATEADD(mm,-12,getdate()),120) and CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,-6,getdate()),120) group by t1.fagentnum,fsaler) t1
|
|
|
inner join (
|
|
|
select fagentnum,sum(t.famount) famount,fsaler from
|
|
|
-(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(t2.famount-isnull(fwriteoffamount,0),0) famount from saorder t1
|
|
|
+(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(fwriteoffamount,0) famount from saorder t1
|
|
|
inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
|
|
|
left join sainvoicedetail t4 on t4.fsourceid=t2.saorderdetailid and t4.siteid=t2.siteid
|
|
|
left join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
@@ -85,7 +85,7 @@ inner join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|
|
|
where t1.fstatus in('审核','关闭') and t3.fstatus='关闭' and t1.siteid=@siteid and CONVERT(VARCHAR(10),t1.checkdate,120)<=CONVERT(VARCHAR(10),DATEADD(mm,-12,getdate()),120) group by t1.fagentnum,fsaler) t1
|
|
|
inner join (
|
|
|
select fagentnum,sum(t.famount) famount,fsaler from
|
|
|
-(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(t2.famount-isnull(fwriteoffamount,0),0) famount from saorder t1
|
|
|
+(select distinct t2.saorderdetailid,t1.fagentnum,t1.fsaler,isnull(fwriteoffamount,0) famount from saorder t1
|
|
|
inner join saorderdetail t2 on t1.siteid=t2.siteid and t1.saorderid=t2.fparentid
|
|
|
left join sainvoicedetail t4 on t4.fsourceid=t2.saorderdetailid and t4.siteid=t2.siteid
|
|
|
left join sainvoice t3 on t4.siteid=t3.siteid and t4.fparentid=t3.sainvoiceid
|