# Can a chart use a SQL view?

**URL:** <https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732>\
**Category:** Ignition\
**Created:** [December 19, 2013, 3:27pm UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732 "2013-12-19T15:27:50Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![SonicClang](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@SonicClang](https://forum.inductiveautomation.com/u/SonicClang)\
**Post date:** [December 19, 2013, 3:27pm UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732/1 "2013-12-19T15:27:50Z")

</div>

Can I populate a chart using a SQL view? I have views that give me just the data I want to see. I would like to use Ignition’s charts to display that data, but I can’t figure out how.

---

<div class="post-metadata">

**Author:** ![Dravik](https://avatars.discourse-cdn.com/v4/letter/d/e274bd/32.png) [@Dravik](https://forum.inductiveautomation.com/u/Dravik)\
**Post date:** [December 19, 2013, 9:30pm UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732/2 "2013-12-19T21:30:25Z")

</div>

The classic chart will work for this, You can bind the dataset to a view w/out trouble.

I don’t think the Easy Chart will right now though?

---

<div class="post-metadata">

**Author:** ![SonicClang](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@SonicClang](https://forum.inductiveautomation.com/u/SonicClang)\
**Post date:** [December 23, 2013, 2:57pm UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732/3 "2013-12-23T14:57:48Z")

</div>

Thank you, Dravik. Could you by any chance point me in the direction of some instructions for that?

Update: Ok, I figured out how to connect it to the view (I think…). Now it’s just a matter of figuring out how to show the columns I want.

---

<div class="post-metadata">

**Author:** ![Paul.Scott](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul.scott/32/4578_2.png) [@Paul.Scott](https://forum.inductiveautomation.com/u/Paul.Scott)\
**Post date:** [December 26, 2013, 7:52pm UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732/4 "2013-12-26T19:52:52Z")

</div>

If you bind the Chart Component’s Data property to a SQL Query, you could pick and choose which columns you need the Chart to display. For example:

```auto
SELECT [column1], [column2] 
FROM [view]
```

---

<div class="post-metadata">

**Author:** ![Robert.McKenzie](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/robert.mckenzie/32/4134_2.png) [@Robert.McKenzie](https://forum.inductiveautomation.com/u/Robert.McKenzie)\
**Post date:** [December 28, 2013, 12:40am UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732/5 "2013-12-28T00:40:58Z")

</div>

Either chart should allow you to use data from a view since views are queried in the same way as any table. IE populate the data property of a simple chart with a SQL Query:`SELECT col1, co2 FROM myview WHERE x`or populate the DB pens of an Easy chart by typing the view name in the table name field and the column in the value field.

Just be careful because every time the view is queried, it will go run the query that populates it.

---

<div class="post-metadata">

**Author:** ![SonicClang](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@SonicClang](https://forum.inductiveautomation.com/u/SonicClang)\
**Post date:** [December 30, 2013, 3:27pm UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732/6 "2013-12-30T15:27:52Z")

</div>

Robert, is there a way to set the refresh rate of the chart? I don’t need it to refresh more than once every 30 seconds.

---

<div class="post-metadata">

**Author:** ![SonicClang](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@SonicClang](https://forum.inductiveautomation.com/u/SonicClang)\
**Post date:** [December 30, 2013, 3:33pm UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732/7 "2013-12-30T15:33:49Z")

</div>

I just noticed the polling rate field on the chart binding screen. If I set this to 30 seconds, will Ignition only query the view every 30 seconds?

---

<div class="post-metadata">

**Author:** ![nmudge](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nmudge/32/3394_2.png) [@nmudge](https://forum.inductiveautomation.com/u/nmudge)\
**Post date:** [December 30, 2013, 4:17pm UTC](https://forum.inductiveautomation.com/t/can-a-chart-use-a-sql-view/7732/8 "2013-12-30T16:17:58Z")

</div>

Yes if the Polling Mode is set to Absolute. If the polling mode is Relative then it will be the base rate + 30 seconds. The project Base Rate is 5 seconds by default and the setting exists in the Project Properties under Client -\> Timing.
