# SQL returns dataset not single value

**URL:** <https://forum.inductiveautomation.com/t/sql-returns-dataset-not-single-value/44576>\
**Category:** Ignition\
**Created:** [March 17, 2021, 1:50pm UTC](https://forum.inductiveautomation.com/t/sql-returns-dataset-not-single-value/44576 "2021-03-17T13:50:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntheuer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@ntheuer](https://forum.inductiveautomation.com/u/ntheuer)\
**Post date:** [March 17, 2021, 1:50pm UTC](https://forum.inductiveautomation.com/t/sql-returns-dataset-not-single-value/44576/1 "2021-03-17T13:50:01Z")

</div>

So this is probably going to be a pretty noobish question, but I tried to summarize as easily as possible in the pictures. Basically I would like system to check this table for an existing record for this work order and retrieve the part number from that table. When I run the change script to detect an entered work order and retrieve the corresponding part number, I get a dataset instead of a single value. How do I tell my SQL to only retrieve the part number and not the column heading?

Also, I would like to make sure that if this returns a null value, that the script does not execute. What would I alter with my change script to make this so?

thanks!

 ![help](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/1/b14761f53e4269cc067ddd336a212799a6103be0.png)

---

<div class="post-metadata">

**Author:** ![ntheuer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@ntheuer](https://forum.inductiveautomation.com/u/ntheuer)\
**Post date:** [March 17, 2021, 1:59pm UTC](https://forum.inductiveautomation.com/t/sql-returns-dataset-not-single-value/44576/2 "2021-03-17T13:59:16Z")

</div>

OK I ended up solving this but being new I am sure this is not the most elegant way to do this. Anybody feel like showing me how to optimize this?

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/a/4a173e8bfccf7302c355cb6488bb0700648db155.png)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [March 17, 2021, 2:07pm UTC](https://forum.inductiveautomation.com/t/sql-returns-dataset-not-single-value/44576/3 "2021-03-17T14:07:28Z")

</div>

In the named query configuration where you edit the sql, you can say that the query is a scalar query and then it will return `[0][0]` by default.

---

<div class="post-metadata">

**Author:** ![ntheuer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@ntheuer](https://forum.inductiveautomation.com/u/ntheuer)\
**Post date:** [March 17, 2021, 5:14pm UTC](https://forum.inductiveautomation.com/t/sql-returns-dataset-not-single-value/44576/4 "2021-03-17T17:14:03Z")

</div>

Yup that fixed it, and cleaned up the code quite nicely. Thanks!
