# SQL Assistance, Changing "true" to 1, "false" to 0 leave oth

**URL:** <https://forum.inductiveautomation.com/t/sql-assistance-changing-true-to-1-false-to-0-leave-oth/9576>\
**Category:** Ignition\
**Created:** [January 20, 2015, 7:16pm UTC](https://forum.inductiveautomation.com/t/sql-assistance-changing-true-to-1-false-to-0-leave-oth/9576 "2015-01-20T19:16:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tbackus](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/tbackus/32/5091_2.png) [@tbackus](https://forum.inductiveautomation.com/u/tbackus)\
**Post date:** [January 20, 2015, 7:16pm UTC](https://forum.inductiveautomation.com/t/sql-assistance-changing-true-to-1-false-to-0-leave-oth/9576/1 "2015-01-20T19:16:31Z")

</div>

Ok I have a column AttrValue  
In that Column, I have various values

3.124  
0  
2.451  
3.1  
true  
1.15  
false  
4.23

Here is the SQL query so far (at least part of it dealing with true false)…

```auto
SELECT TimeStamp, AttrName, (CASE WHEN (AttrValue LIKE '%true%') then 1 else 0 end) FROM QUAL_SampleData WHERE SampleUUID = '05292061-53fb-4e11-acdd-b153b7b82ed2'
```

But what do I need to include to leave the rest of the values as is… Most examples I find deal with entire colmns being boolean and not just some of the fields.

What I want the data to show as is:

3.124  
0  
2.451  
3.1  
1  
1.15  
0  
4.23

It’s been about 15 years since I have done much SQL work, so think “dummies guide to SQL” with responses please. 🙂

---

<div class="post-metadata">

**Author:** ![CPowell](https://avatars.discourse-cdn.com/v4/letter/c/a183cd/32.png) [@CPowell](https://forum.inductiveautomation.com/u/CPowell)\
**Post date:** [January 20, 2015, 8:54pm UTC](https://forum.inductiveautomation.com/t/sql-assistance-changing-true-to-1-false-to-0-leave-oth/9576/2 "2015-01-20T20:54:10Z")

</div>

Try:

```auto
SELECT TimeStamp, AttrName, 
	CASE WHEN AttrValue = 'true'
	THEN 1
	WHEN AttrValue = 'false'
	THEN 0
	ELSE AttrValue
	END AS AttrValue
FROM QUAL_SampleData 
WHERE SampleUUID = '05292061-53fb-4e11-acdd-b153b7b82ed2'

```
