Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有表 REG,我想从 3 个最新字段(mood)值中计算平均值。我使用这个 sql,但这是错误的。
mood
select AVG(mood) AS sent from reg ORDER BY mood DESC LIMIT 3
尝试在子查询中预先选择您想要的值,然后对它们进行平均(假设您使用的是使用Limit关键字的 DBMS):
Limit
Select Avg(tmp.Mood) From (Select Mood From reg order by CreateDate ASC Limit 3) as tmp