划分一列以获得MySQL查询中员工的月薪?
让我们首先创建一个表-
mysql> create table DemoTable1957 ( EmployeeId int, EmployeeName varchar(20), EmployeeSalary int );
使用插入命令在表中插入一些记录-
mysql> insert into DemoTable1957 values(1,'Chris',240000); mysql> insert into DemoTable1957 values(2,'Bob',120000); mysql> insert into DemoTable1957 values(3,'David',180000); mysql> insert into DemoTable1957 values(4,'Mike',650000);
使用select语句显示表中的所有记录-
mysql> select * from DemoTable1957;
这将产生以下输出-
+------------+--------------+----------------+ | EmployeeId | EmployeeName | EmployeeSalary | +------------+--------------+----------------+ | 1 | Chris | 240000 | | 2 | Bob | 120000 | | 3 | David | 180000 | | 4 | Mike | 650000 | +------------+--------------+----------------+ 4 rows in set (0.00 sec)
这是获取员工月薪的查询:
mysql> select EmployeeName,EmployeeSalary/12 As MonthlySalary from DemoTable1957;
这将产生以下输出-
+--------------+---------------+ | EmployeeName | MonthlySalary | +--------------+---------------+ | Chris | 20000.0000 | | Bob | 10000.0000 | | David | 15000.0000 | | Mike | 54166.6667 | +--------------+---------------+ 4 rows in set (0.00 sec)
热门推荐
1 训练狗狗基础
2 怎么训练狗狗笑
3 怎么训练狗狗卧下
4 上海狗狗训练基地
5 训练狗狗排便
6 狗狗基础训练
8 如何训练狗狗装死
9 狗狗站姿训练
10 狗狗训练用品
11 训练狗狗吧
12 狗狗要怎么训练
13 怎么训练狗狗玩球
14 训练狗狗唤回
15 狗狗训练躺下
16 狗狗训练指令
17 狗狗的训练技巧
18 狗狗不好训练