# Sql\_last\_value with tracking column

**URL:** <https://discuss.elastic.co/t/sql-last-value-with-tracking-column/105639>\
**Category:** Logstash\
**Created:** [October 28, 2017, 11:43am UTC](https://discuss.elastic.co/t/sql-last-value-with-tracking-column/105639 "2017-10-28T11:43:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mkarmi](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@mkarmi](https://discuss.elastic.co/u/mkarmi)\
**Post date:** [October 28, 2017, 11:43am UTC](https://discuss.elastic.co/t/sql-last-value-with-tracking-column/105639/1 "2017-10-28T11:43:24Z")

</div>

I'm little confused with the "clean\_run" option. from documentation it says "If clean\_run is set to true, this value will be ignored and sql\_last\_value will be set to Jan 1, 1970, or 0 if use\_column\_value is true, as if no query has ever been executed."

then how will the following statement works if sql\_last\_value is set to 0

statement ="select defect\_id,owned\_by,severity,status,summary,application,created\_by,creation\_date,modified\_by,modified\_date,assigned\_to from defect\_detail where defect\_id\>:sql\_last\_value order by defect\_id"  
#Below is configuration when want to use last run value  
clean\_run=true  
use\_column\_value =true  
tracking\_column =defect\_id  
record\_last\_run =true

will the "record\_last\_run" solve it ? can anyone explain

---

<div class="post-metadata">

**Author:** ![magnusbaeck](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/magnusbaeck/32/44943_2.png) [@magnusbaeck](https://discuss.elastic.co/u/magnusbaeck)\
**Post date:** [October 31, 2017, 6:16am UTC](https://discuss.elastic.co/t/sql-last-value-with-tracking-column/105639/2 "2017-10-31T06:16:12Z")

</div>

I don't understand the question. If `clean_run` is set to true the `sql_last_value` query parameter will be set to zero, so that query will become

```
select defect_id,owned_by,severity,status,summary,application,created_by,creation_date,modified_by,modified_date,assigned_to
from defect_detail where defect_id>0 order by defect_id

```

which presumably selects all rows in the table. When those rows have been processed the id of the last row will be saved until the next run (and then you've presumably cleared `clean_run`).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 28, 2017, 6:16am UTC](https://discuss.elastic.co/t/sql-last-value-with-tracking-column/105639/3 "2017-11-28T06:16:29Z")

</div>

Closed on November 28, 2017, 6:16am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
