Making SQL code into BAQ

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.

THEN add the fields you want to see in the Display FIelds section, but make sure that you do the calculated field for the value you want to sum:

Here is the calculated field:

I will be adding a few more table. I was trying to figure out how to get the baq to say
With LaborData as

Just figured out it is with CTE Query. The group by is a big help though. Had not figured that out yet.