select
uw.keyf_workerid,
uw.name_last || ', ' || uw.name_first as worker,
um.name_last || ', ' || um.name_first as manager,
o.keyp_orderid as orderid,
o.job_title,
s.name_supplier,
l.city,
l.state,
ab.address1,
ab.address2,
ab.zip,
t.keyp_timecardid,
t.status,
t.week_ending as tc_we,
t.hours_regular,
t.hours_ot,
t.hours_dt,
t.hours_holiday,
t.expenses,
t.sales_tax,
t.adjustment,
t.amount_bill_client,
t.amount_pay_supplier,
i.keyp_invoiceid,
i.week_ending as invoice_we,
o.custom_field01 as "Business Area",
d1.department_number,
d1.name_department as "Home Cost Center",
d2.name_department as "Company Code"
from timecard t
           left join invoice i on t.keyf_invoiceid = i.keyp_invoiceid,
     supplier s, location l, address_building ab,
     orders o
           left join users      uw  on   o.keyf_workerid      = uw.keyf_workerid
           left join users      um  on   o.keyf_managerid     = um.keyf_managerid
           left join department d1  on   o.keyf_departmentid  = d1.keyp_departmentid
           left join department d2  on  d1.keyf_parentid      = d2.keyp_departmentid
where
t.keyf_invoiceid        = i.keyp_invoiceid  and
t.keyf_orderid          = o.keyp_orderid    and
o.keyf_supplierid       = s.keyp_supplierid and
o.keyf_locationid       = l.keyp_locationid and
o.keyf_address_buildingid = ab.keyp_address_buildingid and
o.keyf_clientid         = 8                 and
t.week_ending >= '04/02/2006' and
t.week_ending <='04/30/2006'
order by 2, 5;