select sum(Invoice_Amount) as Invoice_amount,
COUNT(*) as Invoice_Count
from Payment_Exception pe
inner join Invoice_Details ind on ind.Customer_ReferenceId = pe.Id
where pe.Customer_Code = '1001012'
and ind.Status='Submit'
答案 0 :(得分:1)
select sum(Invoice_Amount) as Invoice_amount,COUNT(*) as Invoice_Count
from Payment_Exception pe inner join Invoice_Details ind on ind.Customer_ReferenceId=pe.Id
where pe.Customer_Code='1001012' and ind.Status='Submit'
and ind.invoice_date>=DATEADD(m,-6,getdate())
group by Invoice_Amount
您还需要按条件添加分组。
答案 1 :(得分:0)
select sum(Invoice_Amount)
as Invoice_amount,COUNT(*) as Invoice_Count
from Payment_Exception pe
inner join Invoice_Details ind on ind.Customer_ReferenceId=pe.Id
where pe.Customer_Code='1001012' and ind.Status='Submit' and
ind.Insert_Date > dateadd(m, -6, getdate() - datepart(d, getdate()) + 1)