# Editing query in Toad - adding CASE WHEN THEN ELSE

**URL:** <https://forums.toadworld.com/t/editing-query-in-toad-adding-case-when-then-else/58102>\
**Category:** Toad Data Point & Toad Intelligence Central\
**Created:** [September 7, 2023, 9:21pm UTC](https://forums.toadworld.com/t/editing-query-in-toad-adding-case-when-then-else/58102 "2023-09-07T21:21:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chicago\_city\_slicker](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/chicago_city_slicker/32/15862_2.png) [@Chicago\_city\_slicker](https://forums.toadworld.com/u/Chicago_city_slicker)\
**Post date:** [September 7, 2023, 9:21pm UTC](https://forums.toadworld.com/t/editing-query-in-toad-adding-case-when-then-else/58102/1 "2023-09-07T21:21:21Z")

</div>

Hello Toad community,  
I am trying to insert a Case When statement into an existing query. I keep getting an error message. What am I doing wrong? I noticed the very tiny red flag in the line after the End appendage. Is this the problem? How can I resolve this?

![error](https://global.discourse-cdn.com/quest/original/2X/5/589e976ad1a3e00e61d7c480375d639a4b484dfb.png)

 ![case when](https://global.discourse-cdn.com/quest/original/2X/9/928161120af005946193a5d01120ef74dd48844d.png)

---

<div class="post-metadata">

**Author:** ![JohnDorlon](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/johndorlon/32/9997_2.png) [@JohnDorlon](https://forums.toadworld.com/u/JohnDorlon)\
**Post date:** [September 7, 2023, 9:24pm UTC](https://forums.toadworld.com/t/editing-query-in-toad-adding-case-when-then-else/58102/2 "2023-09-07T21:24:49Z")

</div>

Is this Toad for Oracle, Toad Data Point, or something else?

Looks like Toad Data Point. You are in the Toad for Oracle forum.

I don't mind moving your post, just let me know which product you've got.

---

<div class="post-metadata">

**Author:** ![Chicago\_city\_slicker](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/chicago_city_slicker/32/15862_2.png) [@Chicago\_city\_slicker](https://forums.toadworld.com/u/Chicago_city_slicker)\
**Post date:** [September 7, 2023, 9:43pm UTC](https://forums.toadworld.com/t/editing-query-in-toad-adding-case-when-then-else/58102/3 "2023-09-07T21:43:29Z")

</div>

Sorry yes, this is for Toad Data Point. Please move it to the correct forum.

Thank you

---

<div class="post-metadata">

**Author:** ![david.franks](https://avatars.discourse-cdn.com/v4/letter/d/e99b99/32.png) [@david.franks](https://forums.toadworld.com/u/david.franks)\
**Post date:** [September 11, 2023, 12:32pm UTC](https://forums.toadworld.com/t/editing-query-in-toad-adding-case-when-then-else/58102/4 "2023-09-11T12:32:09Z")

</div>

I didn't test on my system, but it looks like you just need a comma after the END, because AL3.OH\_QTY cannot be used as the alias for your CASE statement.

---

<div class="post-metadata">

**Author:** ![mercier104\_000](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mercier104\_000](https://forums.toadworld.com/u/mercier104_000)\
**Post date:** [September 11, 2023, 2:14pm UTC](https://forums.toadworld.com/t/editing-query-in-toad-adding-case-when-then-else/58102/5 "2023-09-11T14:14:03Z")

</div>

Hi, Just put an alias for the result of case, but not for a table, because a result case is a calculated field.  
If...  
THEN ...  
ELSE ...  
END as RESULTCASE,
