Hey guys,
I am trying to get this SQL code into a BAQ. Any help would be appreciated.
with LaborData as(
SELECT
a.EmployeeNum,
Cast(a.ClockInDate as smalldatetime) as ClockInTime,
a.LaborHrs,
a.ExpenseCode,
a.IndirectCode,
a.JobNum,
b.Name,
a.LaborNote
FROM ERP21Live.erp.LaborDtl a
left outer join erp.EmpBasic b
on a.Company= b.Company
and a.EmployeeNum = b.EmpID
WHERE a.Company=‘PPI’ AND a.ClockInDate>=‘1/1/2023’ and a.EmployeeNum in (‘sagb’,‘smb’,‘brb’,‘jlb2’) --and a.LaborNote <> ‘BREAK-TIME’ AND a.JobNum=‘’
)
select
a.Name,
sum(a.LaborHrs) as DirectHrs
from LaborData a
where a.IndirectCode <> ‘IDLE’
group by a.Name
seems fairly simple in a baq… You need to add the appropriate tables, add the criteria, and the display fields… you need to mark the group-by for all the fields except for the calculated field that does the SUM of the Labor Hours.
Note that you also have to join the EmpBasic table to the LaborDtl table to get the employee name that you desired to be displayed.