# Using Conditional Statement in an SQL Query?

**URL:** <https://forum.inductiveautomation.com/t/using-conditional-statement-in-an-sql-query/108963>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [July 25, 2025, 7:23pm UTC](https://forum.inductiveautomation.com/t/using-conditional-statement-in-an-sql-query/108963 "2025-07-25T19:23:15Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [July 25, 2025, 7:46pm UTC](https://forum.inductiveautomation.com/t/using-conditional-statement-in-an-sql-query/108963/4 "2025-07-25T19:46:41Z")

</div>

The link shows an example:

```python
SELECT OrderID, Quantity,
CASE
    WHEN Quantity > 30 THEN 'The quantity is greater than 30'
    WHEN Quantity = 30 THEN 'The quantity is 30'
    ELSE 'The quantity is under 30'
END AS QuantityText
FROM OrderDetails;

```

Replace the table and column names with your table/column names. You may need to remove some columns from the `SELECT` statement as you may not have as many columns. (For example `Quantity` would be replaced by `AshleyVfd_Hz`)

Also, show some examples of SQL statements that you have tried that have not worked. Make sure to post them as [preformatted text](https://forum.inductiveautomation.com/t/wiki-how-to-post-code-on-this-forum/77831).

---

_[View the full topic](https://forum.inductiveautomation.com/t/using-conditional-statement-in-an-sql-query/108963)._
