简体   繁体   English

如何将两个字段相乘然后得到平均行数

[英]how can I multiply two fields then get avg of rows

I want to make avg of grades 我想平均成绩

there is a table like this (INNER JOIN of two table) 有一个这样的表(两个表的INNER JOIN)

+-------+------+
| grade | unit |
+-------+------+

I want to get multiply of (grade & unit) as res 我想将(等级和单位)乘以res

then, get avg of res 然后,获取平均资源

I can do it by php, but i need to make it only with one sql and the result must be in 我可以用php来做,但是我只需要用一个sql来做,结果必须在

one field 一个领域

thank alot 非常感谢

SELECT AVG(grade * unit) FROM ...
select grade,unit, AVG(grade *unit) as average from ... 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM