我想要每个日期部分的最大音量但是当我 运行 它显示

I want max volume of each datesection but when I run it show

SELECT *
FROM
(SELECT
"public".steponesection.datesection,
"public".steponesection."Trade Price",
max ("public".steponesection."Trade Volume") OVER (partition by "public".steponesection.datesection) as max_Volm

FROM "public".steponesection)t

WHERE "public".steponesection."Trade Volume" = max_Volm

导致此错误:

[Err] ERROR:  missing FROM-clause entry for table "steponesection"
LINE 10: WHERE "public".steponesection."Trade Volume" = max_Volm

       ^

错误消息非常清楚:where 子句无法引用 steponesection,因为在该查询级别上没有具有该名称的标识符。派生的 table 称为 t,这就是您需要使用的。

您也没有select内部查询中的"Trade Volume",因此在外部查询中不可用:

SELECT *
FROM (
   SELECT "public".steponesection.datesection,
          "public".steponesection."Trade Price",
          "public".steponesection."Trade Volume",  --<< missing
           max ("public".steponesection."Trade Volume") OVER (partition by "public".steponesection.datesection) as max_volm
   FROM "public".steponesection
) t
WHERE t."Trade Volume" = t.max_volm --<< use the alias of the derived table

我强烈建议避免像 "Trade Price" 这样的带引号的标识符。他们在长 运行 中更麻烦,然后他们值得