从MySQL中的标记中查找百分比

让我们首先创建一个-

create table DemoTable1398
   -> (
   -> Marks int
   -> );

使用insert在表中插入一些记录-

insert into DemoTable1398 values(78);
insert into DemoTable1398 values(82);
insert into DemoTable1398 values(90);
insert into DemoTable1398 values(98);

使用选择显示表中的所有记录-

select * from DemoTable1398;

这将产生以下输出-

+-------+
| Marks |
+-------+
|    78 |
|    82 |
|    90 |
|    98 |
+-------+
4 rows in set (0.00 sec)

以下是查找分数百分比的查询-

select concat(sum(Marks)/count(*),'%') from DemoTable1398;

这将产生以下输出-

+---------------------------------+
| concat(sum(Marks)/count(*),'%') |
+---------------------------------+
| 87.0000%                        |
+---------------------------------+
1 row in set (0.00 sec)
猜你喜欢