# Convert the numbers in field to text format using SQL query using report

**URL:** <https://forum.inductiveautomation.com/t/convert-the-numbers-in-field-to-text-format-using-sql-query-using-report/82109>\
**Category:** Ignition\
**Tags:** python, database, ignition81, scripting, vision\
**Created:** [November 20, 2023, 8:36am UTC](https://forum.inductiveautomation.com/t/convert-the-numbers-in-field-to-text-format-using-sql-query-using-report/82109 "2023-11-20T08:36:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adarsh\_Shelar](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Adarsh\_Shelar](https://forum.inductiveautomation.com/u/Adarsh_Shelar)\
**Post date:** [November 20, 2023, 8:36am UTC](https://forum.inductiveautomation.com/t/convert-the-numbers-in-field-to-text-format-using-sql-query-using-report/82109/1 "2023-11-20T08:36:21Z")

</div>

Hi Connection,

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/9/c980b8149488ce51cd96ea3852500cb423d0f2e5.png)  
As above image is from the report. Where I am getting the data from the data base but while taking the need to convert the Number to test VIA SQL Query

I have 3 sets of data  
0 = not started  
1 = InProgress  
2 = Completed  
How do I convert this above mentioned Number in to the text.

Thanks,  
Connection

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 20, 2023, 10:09am UTC](https://forum.inductiveautomation.com/t/convert-the-numbers-in-field-to-text-format-using-sql-query-using-report/82109/2 "2023-11-20T10:09:06Z")

</div>

You do it in the SQL query. Which SQL database server are you using?

---

<div class="post-metadata">

**Author:** ![Adarsh\_Shelar](https://avatars.discourse-cdn.com/v4/letter/a/f07891/32.png) [@Adarsh\_Shelar](https://forum.inductiveautomation.com/u/Adarsh_Shelar)\
**Post date:** [November 20, 2023, 10:14am UTC](https://forum.inductiveautomation.com/t/convert-the-numbers-in-field-to-text-format-using-sql-query-using-report/82109/3 "2023-11-20T10:14:35Z")

</div>

Oracle SQL data base Sever I am using. can I know how I do can execute in the query?

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [November 20, 2023, 10:25am UTC](https://forum.inductiveautomation.com/t/convert-the-numbers-in-field-to-text-format-using-sql-query-using-report/82109/4 "2023-11-20T10:25:01Z")

</div>

Use the CASE ... WHEN ... syntax. It should be something like this if the number value is in column3:

```auto
SELECT
    column1,
    column2,
    CASE column3
        WHEN 2 THEN 'Completed'
        WHEN 1 THEN 'In Progress'
        ELSE 'Not started'
    END Status,
    column4
FROM ...

```

You will find plenty of examples on the web.

---

<div class="post-metadata">

**Author:** ![MSviga](https://avatars.discourse-cdn.com/v4/letter/m/3e96dc/32.png) [@MSviga](https://forum.inductiveautomation.com/u/MSviga)\
**Post date:** [November 20, 2023, 10:40am UTC](https://forum.inductiveautomation.com/t/convert-the-numbers-in-field-to-text-format-using-sql-query-using-report/82109/5 "2023-11-20T10:40:34Z")

</div>

The way I handle this is to create a new table for status and then connect them via the ID columns. I find it easier to maintain the SQL queries long term this way. However if creating a new table is not an option, then the solution given by @Transistor is your best bet.  
 ![9B3PDiW](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0db4f95b28c3eb864e828e05faddb4bf108ebe40.png)
