# Including Script Module in Query

**URL:** <https://forum.inductiveautomation.com/t/including-script-module-in-query/8840>\
**Category:** General Discussion\
**Created:** [August 1, 2014, 2:10pm UTC](https://forum.inductiveautomation.com/t/including-script-module-in-query/8840 "2014-08-01T14:10:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Raeven](https://avatars.discourse-cdn.com/v4/letter/r/47e85d/32.png) [@Raeven](https://forum.inductiveautomation.com/u/Raeven)\
**Post date:** [August 1, 2014, 2:10pm UTC](https://forum.inductiveautomation.com/t/including-script-module-in-query/8840/1 "2014-08-01T14:10:17Z")

</div>

So I have a label that gets its value from a query:

```auto
SELECT sum(amount) 
FROM tblwaste
WHERE plant = 'Frederick' and mdate > '20140731' and computer = 'frwastecol01'
```

The problem is that I would like to only select values from the previous shift. To do this, I wrote a script module called “FindShiftStartTime”. Is there any way I can call this script module from my query?

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [August 1, 2014, 4:58pm UTC](https://forum.inductiveautomation.com/t/including-script-module-in-query/8840/2 "2014-08-01T16:58:39Z")

</div>

It may be possible, but to make everything a bit cleaner, maybe you could just create a scripting function that also runs the query, and try to bind the label to a [tt]runScript(…)[/tt] function that calls it?

Otherwise, I’d probably create a custom property on the label (or somewhere else, if this shift is needed in multiple places) called “ShiftId” or whatever, and bind that to a runScript that calls the function, and then reference that property inside of the query.

Regards,
