| | |
| | | SUM(slp.tax_inclusive_total_price) AS purchaseAmount, |
| | | COUNT(DISTINCT slp.sales_ledger_id) AS purchaseTimes, |
| | | <!-- 平均单价 = 总采购金额/总采购数量,保留2位小数,避免除0 --> |
| | | ROUND(IF(SUM(slp.quantity) = 0, 0, SUM(slp.tax_inclusive_total_price) / SUM(slp.quantity)), 2) AS averagePrice, |
| | | ROUND(IF(SUM(slp.quantity) = 0, 0, SUM(slp.tax_inclusive_total_price) / SUM(slp.quantity)), 6) AS averagePrice, |
| | | <!-- 该产品大类下最后一个录入日期(取台账主表的entry_date) --> |
| | | MAX(sl.entry_date) AS entryDate, |
| | | COALESCE(NULLIF(SUM(t1.return_quantity), 0), 0) AS return_quantity, |