如何显示每个类别的最大值?

时间:2019-05-10 22:09:07

标签: sql ms-access

使用Microsoft Access,我在Max_value列中仅显示每个区域具有最大值的类别时遇到问题。

表1包含以下行,其中包含:operation_id,region_name,id_of_product,price_of_product和quantity_of_product。 表2包含:id_of_product和category_name。

以下代码可以很好地显示每个区域中每个类别的值,但是“ round()”函数上的简单max(...)似乎无法解决最大问题,因为命令被拒绝被执行。

SELECT region, category, Round(Sum(Value),2) AS Max_Value
FROM (SELECT Table1.operation_id,
             Table1.region_name AS region,
             Table1.price_of_product * Table1.quantity_of_product AS Value,
             Table2.category_name AS category 

        FROM Table1
  INNER JOIN Table2 
         ON Table1.id_of_product = Table2.id_of_product)

GROUP BY region, category;

我正在寻找类似的输出

region    | category | Max_Value
-
Manhattan | fruit    | 2011,23
-
Brooklyn  | sweets   | 391,15
-

等...

0 个答案:

没有答案