mysql加减乘除_mysql中加减乘除与求余和求平均值以及查询不等于某数值的实例...

1.mysql加减乘除操作:mysql> select score,score+5,score-5,score*5,score/5 from 4a;

+-------+---------+---------+---------+---------+

| score | score+5 | score-5 | score*5 | score/5 |

+-------+---------+---------+---------+---------+

| 93 | 98 | 88 | 465 | 18.6000 |

| 35 | 40 | 30 | 175 | 7.0000 |

| 46 | 51 | 41 | 230 | 9.2000 |

| 56 | 61 | 51 | 280 | 11.2000 |

| 79 | 84 | 74 | 395 | 15.8000 |

| 91 | 96 | 86 | 455 | 18.2000 |

| 53 | 58 | 48 | 265 | 10.6000 |

| 56 | 61 | 51 | 280 | 11.2000 |

| 58 | 63 | 53 | 290 | 11.6000 |

| 68 | 73 | 63 | 340 | 13.6000 |

| 71 | 76 | 66 | 355 | 14.2000 |

| 93 | 98 | 88 | 465 | 18.6000 |

| 67 | 72 | 62 | 335 | 13.4000 |

| 78 | 83 | 73 | 390 | 15.6000 |

| 88 | 93 | 83 | 440 | 17.6000 |

| 90 | 95 | 85 | 450 | 18.0000 |

| 92 | 97 | 87 | 460 | 18.4000 |

| 47 | 52 | 42 | 235 | 9.4000 |

| 68 | 73 | 63 | 340 | 13.6000 |

| 78 | 83 | 73 | 390 | 15.6000 |

| 81 | 86 | 76 | 405 | 16.2000 |

| 88 | 93 | 83 | 440 | 17.6000 |

+-------+---------+---------+---------+---------+

22 rows in set (0.00 sec)

2.mysql求余操作:mysql> select score,score%5 from 4a;

+-------+---------+

| score | score%5 |

+-------+---------+

| 93 | 3 |

| 35 | 0 |

| 46 | 1 |

| 56 | 1 |

| 79 | 4 |

| 91 | 1 |

| 53 | 3 |

| 56 | 1 |

| 58 | 3 |

| 68 | 3 |

| 71 | 1 |

| 93 | 3 |

| 67 | 2 |

| 78 | 3 |

| 88 | 3 |

| 90 | 0 |

| 92 | 2 |

| 47 | 2 |

| 68 | 3 |

| 78 | 3 |

| 81 | 1 |

| 88 | 3 |

+-------+---------+

22 rows in set (0.00 sec)

3.mysql求平均值操作:mysql> select score,avg(score) from 4a;

+-------+------------+

| score | avg(score) |

+-------+------------+

| 93 | 71.6364 |

+-------+------------+

1 row in set (0.00 sec)

4.mysql求不等于某数值操作:mysql> select score,score!=88 from 4a;

+-------+-----------+

| score | score!=88 |

+-------+-----------+

| 93 | 1 |

| 35 | 1 |

| 46 | 1 |

| 56 | 1 |

| 79 | 1 |

| 91 | 1 |

| 53 | 1 |

| 56 | 1 |

| 58 | 1 |

| 68 | 1 |

| 71 | 1 |

| 93 | 1 |

| 67 | 1 |

| 78 | 1 |

| 88 | 0 |

| 90 | 1 |

| 92 | 1 |

| 47 | 1 |

| 68 | 1 |

| 78 | 1 |

| 81 | 1 |

| 88 | 0 |

+-------+-----------+

22 rows in set (0.00 sec)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值