---
title: "SQL CAST Function Convert Numeric to Decimal"
description: "CAST function rules to convert NULL value as an integer of Char."
url: https://srinimf.com/2012/04/17/db2-cast-function/
date: 2012-04-17
modified: 2026-10-05
author: "Srini"
image: https://i0.wp.com/srinimf.com/wp-content/uploads/2012/04/sql-cast-1.jpg?fit=475%2C331&ssl=1
categories: ["SQL"]
tags: ["SQL CAST Function"]
type: post
lang: en
---

# SQL CAST Function Convert Numeric to Decimal

Here is an [SQL query](https://srinimf.com/2018/04/01/sql-query-numeric-function-used-in-real-time-banking-project/) on converting numeric column type to Decimal. If we talk at very low-level, [cast function](https://srinimf.com/2021/03/06/how-to-use-cast-function-in-analytics/) converts one column [data type](https://srinimf.com/2016/09/21/how-to-use-sum-function-the-best-way-in-sql/) into another data-type.

## SQL CAST example

```
SELECT DEPT_NAME, CAST(DEPT_AMT AS DECIMAL(10,2))
FROM DEPT_TABLE;
```

It is very clear from the above example that, DEPT_AMT is a numeric column, then CAST converts it into Decimal(10,2). This is the fundamental use of CAST.

- There are limitations on converting [data types](https://srinimf.com/2022/12/24/these-are-user-defined-data-types-in-db2/).  
- With CAST function , You can convert NULL as integer or Char etc.,
- The data conversion CAST (NULL AS INTEGER). This is for single row value.

Keep Reading

[![How to Use CAST Function: 5 Tricky SQL Queries](https://i0.wp.com/srinimf.com/wp-content/uploads/2021/03/pexels-photo-6147378.jpeg?fit=600%2C400&ssl=1)](https://srinimf.com/2021/03/06/how-to-use-cast-function-in-analytics/)

### [How to Use CAST Function: 5 Tricky SQL Queries](https://srinimf.com/2021/03/06/how-to-use-cast-function-in-analytics/)

[![Srini&apos;s avatar](https://secure.gravatar.com/avatar/f10b4bafeeb96dce9806c5a3c6cde6ea1e2c014ef273120a4bf2c6d5f975f01c?s=48&r=g)](https://srinimf.com/author/moonrobot/)
by [Srini](https://srinimf.com/author/moonrobot/)
March 6, 2021

[![SQL CAST Function: How to Convert CHAR to VARCHAR](https://i0.wp.com/srinimf.com/wp-content/uploads/2012/04/pexels-photo-5945621.jpeg?fit=600%2C394&ssl=1)](https://srinimf.com/2012/04/24/db2-why-cast-function-needed-2-of-2/)

### [SQL CAST Function: How to Convert CHAR to VARCHAR](https://srinimf.com/2012/04/24/db2-why-cast-function-needed-2-of-2/)

[![Srini&apos;s avatar](https://secure.gravatar.com/avatar/f10b4bafeeb96dce9806c5a3c6cde6ea1e2c014ef273120a4bf2c6d5f975f01c?s=48&r=g)](https://srinimf.com/author/moonrobot/)
by [Srini](https://srinimf.com/author/moonrobot/)
April 24, 2012

[![SQL CAST Function Convert Numeric to Decimal](https://i0.wp.com/srinimf.com/wp-content/uploads/2012/04/sql-cast-1.jpg?fit=475%2C331&ssl=1)](https://srinimf.com/2012/04/17/db2-cast-function/)

### [SQL CAST Function Convert Numeric to Decimal](https://srinimf.com/2012/04/17/db2-cast-function/)

[![Srini&apos;s avatar](https://secure.gravatar.com/avatar/f10b4bafeeb96dce9806c5a3c6cde6ea1e2c014ef273120a4bf2c6d5f975f01c?s=48&r=g)](https://srinimf.com/author/moonrobot/)
by [Srini](https://srinimf.com/author/moonrobot/)
April 17, 2012

### Share this:

-
- [Tweet](https://twitter.com/share)
- [![](https://i0.wp.com/assets.pinterest.com/images/pidgets/pinit_fg_en_rect_gray_20.png)](https://www.pinterest.com/pin/create/link/?url=https%3A%2F%2Fsrinimf.com%2F2012%2F04%2F17%2Fdb2-cast-function%2F&media=https%3A%2F%2Fi0.wp.com%2Fsrinimf.com%2Fwp-content%2Fuploads%2F2012%2F04%2Fsql-cast-1.jpg%3Ffit%3D475%252C331%26ssl%3D1&description=SQL%20CAST%20Function%20Convert%20Numeric%20to%20Decimal)
-
- [Share on Tumblr](https://www.tumblr.com/share)
- [Share on WhatsApp (Opens in new window) WhatsApp](https://srinimf.com/2012/04/17/db2-cast-function/?share=jetpack-whatsapp)
- [More](#)
-

- [Print (Opens in new window) Print](https://srinimf.com/2012/04/17/db2-cast-function/?share=print)
- [Share on Reddit (Opens in new window) Reddit](https://srinimf.com/2012/04/17/db2-cast-function/?share=reddit)
- [Share on Telegram (Opens in new window) Telegram](https://srinimf.com/2012/04/17/db2-cast-function/?share=telegram)
- [Email a link to a friend (Opens in new window) Email](mailto:?subject=%5BShared%20Post%5D%20SQL%20CAST%20Function%20Convert%20Numeric%20to%20Decimal&body=https%3A%2F%2Fsrinimf.com%2F2012%2F04%2F17%2Fdb2-cast-function%2F&share=email)
-

### Like this:

Like Loading…
