# Difference between revisions of "CEIL"

From SQLZOO

Line 20: | Line 20: | ||

In this example we calculate the population in millions. | In this example we calculate the population in millions. | ||

<source lang='sql' class='def e-sqlserver'> | <source lang='sql' class='def e-sqlserver'> | ||

− | SELECT | + | SELECT population/1000000 AS a, |

− | FLOOR(population/1000000) | + | FLOOR(population/1000000) AS b |

FROM bbc | FROM bbc | ||

</source> | </source> |

## Revision as of 14:37, 16 July 2012

CEIL(f) | ||
---|---|---|

Engine | OK | Alternative |

ingres | Yes | |

mysql | Yes | |

oracle | Yes | |

postgres | Yes | |

sqlserver | No | FLOOR(-f) |

# CEIL

CEIL(f) is ceiling, it returns the integer that is equal to or just more than f

CEIL(f) give the integer that is equal to, or just higher than f. CEIL always rounds up.

CEIL(2.7) -> 2 CEIL(-2.7) -> -3

In this example we calculate the population in millions.

SELECT population/1000000 AS a, FLOOR(population/1000000) AS b FROM bbc

SELECT population/1000000 AS a, CEIL(population/1000000) AS b FROM bbc

See also