# Need help adding Table Criteria

**URL:** <https://www.epiusers.help/t/need-help-adding-table-criteria/90283>\
**Category:** Epicor ERP 10\
**Tags:** baq\
**Created:** [May 10, 2022, 4:04pm UTC](https://www.epiusers.help/t/need-help-adding-table-criteria/90283 "2022-05-10T16:04:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![m.viglas](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@m.viglas](https://www.epiusers.help/u/m.viglas)\
**Post date:** [May 10, 2022, 4:04pm UTC](https://www.epiusers.help/t/need-help-adding-table-criteria/90283/1 "2022-05-10T16:04:47Z")

</div>

I have been asked to create a BAQ that calculates average labor hours by job and part over a date range.

I need to add something, that in SQL would be Labor.Dtl.ClockOutTime-Labor.Dtl.ClockinTime\>0  
How can I accomplish this?

Here is my where clause in SQL; I need to know where to add the italicized line to the BAQ

where  
erp.labordtl.expensecode=‘direct’  
and _erp.labordtl.clockouttime-erp.labordtl.clockintime\>0_  
and erp.labordtl.LaborEntryMethod\<\>‘q’  
and erp.jobhead.jobcomplete=1  
and erp.jobhead.JobCompletionDate\>‘01/01/22’ and erp.jobhead.jobcompletiondate\<‘04/01/22’

 ![image](https://www.epiusers.help/uploads/default/original/3X/7/7/7755800a59156d43913527712389360dd12def8d.png)

---

<div class="post-metadata">

**Author:** ![E102016](https://www.epiusers.help/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@E102016](https://www.epiusers.help/u/E102016)\
**Post date:** [May 10, 2022, 4:37pm UTC](https://www.epiusers.help/t/need-help-adding-table-criteria/90283/2 "2022-05-10T16:37:38Z")

</div>

Why not just use LaborDtl.LaborHrs\>0

---

<div class="post-metadata">

**Author:** ![NateS](https://www.epiusers.help/user_avatar/www.epiusers.help/nates/32/18519_2.png) [@NateS](https://www.epiusers.help/u/NateS)\
**Post date:** [May 10, 2022, 4:42pm UTC](https://www.epiusers.help/t/need-help-adding-table-criteria/90283/3 "2022-05-10T16:42:28Z")

</div>

I see what you are trying to get at, but subtracting the times may not be the best option. What if someone starts a job at 11:00pm, them stops the job at 4:00am? I think this would break your BAQ. What about using LaborHrs in the LaborDtl table?

---

<div class="post-metadata">

**Author:** ![NateS](https://www.epiusers.help/user_avatar/www.epiusers.help/nates/32/18519_2.png) [@NateS](https://www.epiusers.help/u/NateS)\
**Post date:** [May 10, 2022, 4:44pm UTC](https://www.epiusers.help/t/need-help-adding-table-criteria/90283/4 "2022-05-10T16:44:04Z")

</div>

If you REALLY want to do it this way, create a calculated field that = clockout-clockin, then set a subquery criteria on that calculated field.

---

<div class="post-metadata">

**Author:** ![m.viglas](https://www.epiusers.help/letter_avatar_proxy/v4/letter/m/b487fb/32.png) [@m.viglas](https://www.epiusers.help/u/m.viglas)\
**Post date:** [May 10, 2022, 5:00pm UTC](https://www.epiusers.help/t/need-help-adding-table-criteria/90283/5 "2022-05-10T17:00:41Z")

</div>

Well I feel like an idiot, the LaborHrs field, I totally missed. Thanks all.
