Difference between revisions of "DIV"
From SQLZOO
(Created page with "<table align='right' border='1'> <caption>Compatibility</caption> <tr><th colspan='3'>a DIV b</th></tr> <tr><td align='center'>'''Engine'''</td><td align='center'>'''OK'''</td...") |
|||
| (2 intermediate revisions by 2 users not shown) | |||
| Line 9: | Line 9: | ||
<tr><td align='left'>sqlserver</td><td>No</td><td>[[FLOOR |FLOOR(a/b)]]</td></tr> | <tr><td align='left'>sqlserver</td><td>No</td><td>[[FLOOR |FLOOR(a/b)]]</td></tr> | ||
</table> | </table> | ||
| + | |||
<h1>DIV</h1> | <h1>DIV</h1> | ||
| − | <p> | + | <p><b>a DIV b</b> returns the integer value of a divided by b. </p> |
<p></p> | <p></p> | ||
<pre style='width:60ex'> | <pre style='width:60ex'> | ||
| Line 20: | Line 21: | ||
<source lang='sql' class='def e-mysql'> | <source lang='sql' class='def e-mysql'> | ||
SELECT name, | SELECT name, | ||
| − | + | population DIV 1000000 | |
FROM bbc | FROM bbc | ||
</source> | </source> | ||
| Line 34: | Line 35: | ||
<li>[[MOD |MOD function]]</li> | <li>[[MOD |MOD function]]</li> | ||
</ul> | </ul> | ||
| + | |||
| + | {{Languages}} | ||
Latest revision as of 21:49, 21 October 2012
| a DIV b | ||
|---|---|---|
| Engine | OK | Alternative |
| ingres | No | FLOOR(a/b) |
| mysql | Yes | |
| oracle | No | FLOOR(a/b) |
| postgres | No | FLOOR(a/b) |
| sqlserver | No | FLOOR(a/b) |
DIV
a DIV b returns the integer value of a divided by b.
8 DIV 3 -> 2
In this example we calculate the population in millions.
SELECT name, population DIV 1000000 FROM bbc
SELECT name, FLOOR(population/1000000) FROM bbc
See also
| Language: | English • Deutsch |
|---|