mysql显示百分比例_显示值mysql的百分比
我有以下數(shù)據(jù)表和數(shù)據(jù):
mysql> describe school_data_sets_numeric_data;
+--------------+----------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------------+----------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| data_set_nid | int(11) | NO | | NULL | |
| school_nid | int(11) | NO | | NULL | |
| year | int(11) | NO | | NULL | |
| description | varchar(255) | NO | | NULL | |
| value | decimal(18,12) | NO | | NULL | |
+--------------+----------------+------+-----+---------+----------------+
6 rows in set (0.00 sec)
+----+--------------+------------+------+-------------------+------------------+
| id | data_set_nid | school_nid | year | description | value |
+----+--------------+------------+------+-------------------+------------------+
| 54 | 19951 | 19944 | 2008 | Asian | 75.000000000000 |
| 51 | 19951 | 19944 | 2008 | White | 200.000000000000 |
| 52 | 19951 | 19944 | 2008 | African American | 100.000000000000 |
| 53 | 19951 | 19944 | 2008 | Hispanic | 50.000000000000 |
| 55 | 19951 | 19944 | 2008 | Native American | 9.000000000000 |
我想顯示數(shù)據(jù)的平均值而不是原始數(shù)字.我想在原始sql中執(zhí)行此操作.
例:
+----+--------------+------------+------+-------------------+------------------+
| id | data_set_nid | school_nid | year | description | average |
+----+--------------+------------+------+-------------------+------------------+
| 54 | 19951 | 19944 | 2008 | Asian | 17.28% |
| 51 | 19951 | 19944 | 2008 | White | 46.06% |
| 52 | 19951 | 19944 | 2008 | African American | 23.04% |
| 53 | 19951 | 19944 | 2008 | Hispanic | 11.52% |
| 55 | 19951 | 19944 | 2008 | Native American | 2.07% |
做這個(gè)的最好方式是什么?請(qǐng)記住,將有多個(gè)數(shù)據(jù)集和年份.
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的mysql显示百分比例_显示值mysql的百分比的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 黄山去阿克苏阿克苏库车大寺有多远
- 下一篇: 李亚鹏被判赔4000万 带你了解具体情况