Create View Vw_Ac_Cash_Sales (Ac_Cash_No,Name,Sale2015,Sale2016,Sal22017) As Select I.Ac_Cash_no,Min(A.Name),Sum(IIf(I.IYear=2015,Total_value*IIf(Inv_Type='1',1,-1),0)) V2015 ,Sum(IIf(I.IYear=2016,Total_value*IIf(Inv_Type='1',1,-1),0)) V2016 ,Sum(IIf(I.IYear=2017,Total_value*IIf(Inv_Type='1',1,-1),0)) V2017  From Invoices I Join VW_ACCOUNTS_CASH_CLIENTS A On I.Ac_Cash_no=A.Ac_no  Where I.Inv_type In ('1','2') And I.IYear>=2015 Group By i.Ac_Cash_no