【发布时间】:2021-12-12 22:03:03
【问题描述】:
上面写着“不是 groupby 函数”。当我将 D.unitpricef 添加到 groupby 时,它没有显示任何错误,但结果它多次显示相同的 itmcode。一项代码应该只显示一次
SELECT
ItemCode,
case when H.InvoType = 1 then concat(ItemCode,' ( SLT Equipment )' ) else concat(ItemCode,' (
CONBES Eqipment )' ) end as EquName,
case when TRIM(SUM(QTY)) is null then '' else TRIM(TO_CHAR(SUM(QTY),'999999')) end as QTY,
CAST( (SUM(QTY) * D.unitpricef) AS NUMBER(38,2)) AS Amount
FROM Invoicedetails D
INNER JOIN
invoiceheader H ON D.InvoiceNo = H.InvoiceNo
INNER JOIN Equipment E ON E.EquCode = ItemCode
WHERE
H.CancelStat= 0
AND H.ReceiptStat = 1
AND H.BCCODE = 'xxx'
GROUP BY ItemCode,H.InvoType ORDER BY ItemCode ASC;
【问题讨论】:
标签: oracle group-by aggregate-functions