mysql> set @daily_room_charge = 100;
Query OK, 0 rows affected (0.02 sec)
mysql> set @num_of_nights = 3;
Query OK, 0 rows affected (0.00 sec)
mysql> set @tax_percent = 8;
Query OK, 0 rows affected (0.00 sec)
mysql> set @total_room_charge = @daily_room_charge * @num_of_nights;
Query OK, 0 rows affected (0.00 sec)
mysql> set @tax = (@total_room_charge * @tax_percent)/100;
Query OK, 0 rows affected (0.02 sec)
mysql> set @total = @total_room_charge + @tax;
Query OK, 0 rows affected (0.00 sec)
mysql> select @total;
+---------------+
| @total |
+---------------+
| 324.000000000 |
+---------------+
1 row in set (0.02 sec)
本文通过SQL语句展示了如何计算酒店房间的总费用,包括每日房价、住宿天数、税费等要素。
275

被折叠的 条评论
为什么被折叠?



