Ansi SQL type casting

Mikhail.Mamaev picture Mikhail.Mamaev · Oct 7, 2009 · Viewed 12.6k times · Source

Is it allowed to cast types in ANSI SQL like in postgres for example:

SELECT SUM( CAST(qnty AS int) - CAST(reserve AS int) )  AS sum
...

qnty and reserve are character columns.

Answer

Lukáš Lalinský picture Lukáš Lalinský · Oct 7, 2009

The CAST expression was added in SQL-92. You can see it for example in this draft.