Difference between revisions of "DIV"

From SQLZOO
Jump to: navigation, search
(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...")
 
Line 20: Line 20:
 
<source lang='sql' class='def e-mysql'>
 
<source lang='sql' class='def e-mysql'>
 
SELECT name,
 
SELECT name,
       FLOOR(population/1000000)
+
       population DIV 1000000
 
   FROM bbc
 
   FROM bbc
 
</source>
 
</source>

Revision as of 10:36, 16 July 2012

Compatibility
a DIV b
EngineOKAlternative
ingresNoFLOOR(a/b)
mysqlYes
oracleNoFLOOR(a/b)
postgresNoFLOOR(a/b)
sqlserverNoFLOOR(a/b)

DIV

aDIVb 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

Personal tools
Namespaces

Variants
Actions
Reference
Toolbox
Google AdSense