From r In ReceiptLines
Where
r.RECEIPT.RECEIPTDATE >= _reportStartDate
And r.RECEIPT.RECEIPTDATE <= _reportEndDate
Let amount = r.QUANTITY * r.PRICE
Let discount = r.RECEIPTDISCOUNTs.Sum(Function(d) d.DISCOUNT)
where discount > 0
Group By Department = r.ITEMSTYLE.ITEM.CATEGORY.DEPARTMENT.DEPARTMENTNAME
Into Sales = Sum(amount - discount),
Average = Average(amount - discount),
Count = Count()
Run Code Online (Sandbox Code Playgroud)
我从ReceiptLine,Receipt,ReceiptDiscount表中获取所有部门及其销售额,平均数.我面临的问题是,如果我删除折扣> 0,我得到null异常.但如果我把它包括在内,那么我只能得到有折扣的销售.我如何编写使所有销售额减少折扣的查询(如果有的话).任何帮助都非常感谢.