我想知道 NUMERIC(5,2) 相對于我的 avg 的正確位置在我下面的 SQL 查詢中的位置:
select distinct
b.name, avg(c.price) over (partition by b.name) as average_price
from
Catalog a
join
books b on (a.book_id = b.id)
join
movies c on (a.movie_id = c.id)
where
c.price is not null
and a.record >= 2
group by
b.name, c.price, average_price
我已經嘗試過無處不在的感覺!
提前致謝。
uj5u.com熱心網友回復:
我只會投平均值:
select distinct b.name,
cast(avg(c.price) over (partition by b.name) as numeric(5,2)) as average_price
from ...
這假設您希望使用price列中的任何原始精度進行平均計算,并且您只想查看輸出為numeric(5,2).
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/367502.html
