Mysql operator DIVIDE
From w3cyberlearnings
Contents |
MySQL DIV operator Function
This operator divides two numbers and returns result.
Syntax DIV
- N1 the first number (dividend)
- N2 the second number (divisor)
N1 / N2
Example 1
mysql> SELECT 44/5; +--------+ | 44/5 | +--------+ | 8.8000 | +--------+ 1 row in set (0.01 sec)
Example 2
mysql> SELECT * FROM totalearn; +----+------------+-------------+ | id | total_hour | hourly_rate | +----+------------+-------------+ | 1 | 30 | 50 | | 2 | 40 | 50 | | 3 | 30 | 80 | | 4 | 34 | 90 | +----+------------+-------------+ 4 rows in set (0.00 sec) mysql> SELECT id, total_hour, -> (hourly_rate/3) as rate -> FROM totalearn; +----+------------+------------------+ | id | total_hour | rate | +----+------------+------------------+ | 1 | 30 | 16.6666666666667 | | 2 | 40 | 16.6666666666667 | | 3 | 30 | 26.6666666666667 | | 4 | 34 | 30 | +----+------------+------------------+ 4 rows in set (0.01 sec)
Related Links
# | Function | Description |
---|---|---|
1 | DIV | Integer division |
2 | / | Division operator |
3 | - | Minus operator |
4 | % or MOD | Modulo operator |
5 | + | Addition operator |
6 | * | Multiplication operator |
7 | - | Change the sign of the argument |