让我们首先创建一个表-
create table DemoTable1606 -> ( -> Value int -> );
使用插入命令在表中插入一些记录-
insert into DemoTable1606 values(5); insert into DemoTable1606 values(10);
使用select语句显示表中的所有记录-
select * from DemoTable1606;
这将产生以下输出-
+-------+ | Value | +-------+ | 5 | | 10 | +-------+ 2 rows in set (0.00 sec)
这是在MySQL中实现谐波均值和二次均值的查询-
select (count(*)/sum(1/Value)) as HarmonicMean, -> sqrt(sum(Value * Value)/count(*)) as QuadraticMean -> from DemoTable1606;
这将产生以下输出-
+--------------+-------------------+ | HarmonicMean | QuadraticMean | +--------------+-------------------+ | 6.6667 | 7.905694150420948 | +--------------+-------------------+ 1 row in set (0.03 sec)