SELECT TO_CHAR(MAX(UnitPrice),'$999D99')AS"Maximum Part Price",
TO_CHAR(Min(UnitPrice),'$99D99')AS "Minimum Part Price",
TO_CHAR(AVG(UnitPrice),'$999D99')AS "Average Part Price",
TO_CHAR((UnitsOnHand*UnitPrice),'$999G999D99') AS "Total Value All Parts"
FROM Part;
嗨,当我尝试这样做时,我一直都会收到错误,直到我添加最后一行都很好..但是我需要最后一行才能做到这一点...一直在尝试约3小时,它在我的头脑中
答案 0 :(得分:0)
SELECT
TO_CHAR(MAX(UnitPrice),'$999D99') AS"Maximum Part Price",
TO_CHAR(MIN(UnitPrice),'$99D99') AS "Minimum Part Price",
TO_CHAR(AVG(UnitPrice),'$999D99') AS "Average Part Price",
TO_CHAR(SUM(UnitsOnHand*UnitPrice),'$999G999D99') AS "Total Value All Parts"
FROM Part
;
尝试求和函数
实施例
SELECT
TO_CHAR(MAX(UnitPrice),'$999D99') AS"Maximum Part Price",
TO_CHAR(MIN(UnitPrice),'$99D99') AS "Minimum Part Price",
TO_CHAR(AVG(UnitPrice),'$999D99') AS "Average Part Price",
TO_CHAR(SUM(UnitsOnHand*UnitPrice),'$999G999D99') AS "Total Value All Parts"
FROM
(
SELECT 1 UnitsOnHand, 20 UnitPrice FROM dual UNION
SELECT 4 UnitsOnHand, 70 UnitPrice FROM dual UNION
SELECT 3 UnitsOnHand, 10 UnitPrice FROM dual UNION
select 7 UnitsOnHand, 2 UnitPrice from dual )
结果
Max Min Avg Sum
$70,00 $2,00 $25,50 $344,00
答案 1 :(得分:0)
我认为这一行导致它获得更多行:
TO_CHAR((UnitsOnHand*UnitPrice),'$999G999D99') AS "Total Value All Parts"
也许您可以将其更改为:
TO_CHAR(MAX((UnitsOnHand*UnitPrice)),'$999G999D99') AS "Total Value All Parts"