让我们首先创建一个表-
mysql> create table DemoTable ( Money DECIMAL(7,2) );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable values(100.67); mysql> insert into DemoTable values(199.33); mysql> insert into DemoTable values(500); mysql> insert into DemoTable values(400); mysql> insert into DemoTable values(800);
使用select语句显示表中的所有记录-
mysql> select *from DemoTable;
这将产生以下输出-
+--------+ | Money | +--------+ | 100.67 | | 199.33 | | 500.00 | | 400.00 | | 800.00 | +--------+ 5 rows in set (0.00 sec)
以下是添加十进制值的查询/-
mysql> select sum(Money) from DemoTable;
这将产生以下输出-
+------------+ | sum(Money) | +------------+ | 2000.00 | +------------+ 1 row in set (0.00 sec)